当前位置: 首页 > news >正文

Codeforces Round 893 (Div. 2)(VP-7,寒假加训)

VP时间

A.

关键在于按c的按钮

c&1

Alice可以多按一次c按钮

也就是a多一个(a++)

之后比较a,b大小即可

!(c&1)

Alice Bob操作c按钮次数一样

1.ac

B.贪心

一开始会吃饼干

如果有卖饼的就吃

如果隔离一段时间到d没吃就吃(当时间快到的时候卖一次饼)

n是长度

枚举一遍卖饼的位置

不移除

吃饼量=((s[i]-s[i-1]-1)/d)求和

s[i]到s[i-1]之间的距离(s[i-1],s[i])不到s[i]因此要-1

枚举一遍卖饼的位置

还有特判(s[0]=1-d,s[m+1]=n+1),-d+1(到1就吃一口饼),n+1(到n可能会吃一口饼)

res-=(s[i]-s[i-1]-1)/d;

res-=(s[i+1]-s[i]-1)/d;

res+=(s[i+1]-s[i-1])/d;

res+=m-1;

计算出res

ans=min(ans,res)

if(ans==res)cnt++;

C.

gcd最大的数是n/2

gcd(a[i],a[i+1])

i,2*i放一起为最优解

i 枚举奇数

1.ac

题解

A.

// Problem: A. Buttons
// Contest: Codeforces - Codeforces Round 893 (Div. 2)
// URL: https://codeforces.com/contest/1858/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void solve() {int a,b,c;cin>>a>>b>>c;if(c&1){a++;if(a>b){cout<<"First"<<'\n';}else{cout<<"Second"<<'\n';}}else{if(a>b){cout<<"First"<<'\n';}else{cout<<"Second"<<'\n';}}}int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int q;cin >> q;while (q--) {solve();}return 0;
}

B.

// Problem: B. The Walkway
// Contest: Codeforces - Codeforces Round 893 (Div. 2)
// URL: https://codeforces.com/contest/1858/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e5 + 9;
int s[N];
void solve() {int n,m,d;cin>>n>>m>>d;for(int i=1;i<=m;i++){cin>>s[i];}s[0]=-d+1;s[m+1]=n+1;int sum=0;for(int i=1;i<=m+1;i++){sum+=(s[i]-s[i-1]-1)/d;		}int ans=n+1;int cnt=0;for(int i=1;i<=m;i++){int res=sum;res-=(s[i]-s[i-1]-1)/d;res-=(s[i+1]-s[i]-1)/d;res+=(s[i+1]-s[i-1]-1)/d;res+=m-1;if(res<ans){ans=res;cnt=1;}else if(res==ans){cnt++;}}cout<<ans<<" "<<cnt<<'\n';}int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int q;cin >> q;while (q--) {solve();}return 0;
}

C.

// Problem: C. Yet Another Permutation Problem
// Contest: Codeforces - Codeforces Round 893 (Div. 2)
// URL: https://codeforces.com/contest/1858/problem/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)//へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// イ● 、 ●  ⊂⊃〈  /
// ()  へ    | \〈
//  >ー 、_  ィ  │ //
//  / へ   / ノ<| \\
//  ヽ_ノ  (_/  │//
//	  7       |/
//	  >―r ̄ ̄`ー―_
#include <iostream>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void solve() {int n;cin>>n;vector<int> a;for(int i=1;i<=n;i+=2){for(int j=i;j<=n;j*=2){a.push_back(j);}}for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
}int main() {ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);int q;cin >> q;while (q--) {solve();}return 0;
}

http://www.lryc.cn/news/275170.html

相关文章:

  • MySQL第四战:视图以及常见面试题(上)
  • C语言程序设计——程序流程控制方法(一)
  • torch.backends.cudnn.benchmark
  • SQL Server从0到1——写shell
  • 计算圆弧的起始角度、终止角度和矩形信息并使用drawArc绘制圆弧
  • C++ Trie树模版 及模版题 || Trie字符串统计
  • Linux基础命令@echo、tail、重定向符
  • uniapp:签字版、绘画板 插件l-signature
  • Python Pillow(PIL)库的用法介绍
  • uniapp 【专题详解 -- 时间】云数据库时间类型设计,时间生成、时间格式化渲染(uni-dateformat 组件的使用)
  • k8s之flink的几种创建方式
  • 应用OpenCV绘制箭头
  • 信息学奥赛一本通1032:大象喝水查
  • 聊聊jvm的direct buffer统计
  • C/C++ 位段
  • Peter算法小课堂—树的应用
  • FineBI:简介
  • 原神单机版【完全无脑搭建】⭐纯单机⭐*稳定版*
  • 用通俗易懂的方式讲解:万字长文带你入门大模型
  • Invalid options in vue.config.js: “plugins“ is not allowed
  • 四、C语言中的数组:数组的创建与初始化
  • html5中各标签的语法格式总结以及属性值说明
  • 力扣(leetcode)第412题Fizz Buzz(Python)
  • 苦学golang半年,写了一款web服务器
  • uniapp vue2 车牌号输入组件记录
  • Unity 点击对话系统(含Demo)
  • vue接入高德地图
  • Linux的基本指令(5)
  • 华为商城秒杀时加密验证 device_data 的算法研究
  • Wrk压测发送Post请求的正确姿势