Codeforces Round #443 (Div. 2) 【A、B、C、D】
Codeforces Round #443 (Div. 2)
codeforces 879 A. Borya's Diagnosis【水题】
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
int n, t = , s, d;
scanf("%d", &n);
while(n--) {
scanf("%d%d", &s, &d);
while(s <= t) {s += d;}
t = s;
}
printf("%d\n", t);
return ;
}
78ms
codeforces 879 B. Table Tennis【模拟】
题意:一排n个人,给出每个人的a值,从第一个人开始,每次和后面人比赛,a值大的人赢,输的人走到最后位置去,求先连赢k场的人的a值。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
long long k;
int n, t = , a, ans = , cnt = , f = ;
scanf("%d%lld", &n, &k);
while(n--) {
scanf("%d", &a);
if(a < ans) cnt++;
else cnt = ;
ans = max(ans, a);
if(!f) {cnt = ;f = ;}
if(cnt >= k) break;
}
printf("%d\n", ans);
return ;
}
31ms
codeforces 878 A. Short Program【位运算】
题意:给出一系列与、或、异或这三种逻辑运算表达式,要对未知数x顺序做这些运算,要你合并运算,输出不超过5行的化简的运算式子。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int main(){
int i, j, k, f, x;
int cnt = ;
int a = , b = , c = ;
char s;
scanf("%d", &n);
for(i = ; i <= n; ++i) {
getchar();
scanf("%c %d", &s, &x);
if(s == '|') {a |= x; b |= x; c &= (-x);}
else if(s == '&') {b &= x; c &= x;}
else if(s =='^') {c ^= x; }
}
if(a) cnt++;
if(b != ) cnt++;
if(c) cnt++;
printf("%d\n", cnt);
if(a) printf("| %d\n", a);
if(b != ) printf("& %d\n", b);
if(c) printf("^ %d\n", c);
return ;
}
156ms
codeforces 878 B. Teams Formation【模拟】
题意:长为n的数组a,重复m次形成一个序列,每次动态消去相邻k个相同的数,直到不能消去为止,求最后剩下几个数。
题解:先将长为n的一列数消除,然后考虑两段连接中间消除。
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = ;
typedef long long ll;
int n, k, m, cnt;
int a[N], b[N], c[N];
ll ans = ;
int main() {
cnt = ;
int i, j, o, sum = ;
int l, r;
scanf("%d%d%d", &n, &k, &m);
for(i = ; i <= n; ++i) scanf("%d", &a[i]);
for(i = ; i <= n; ++i) {//第一段序列
if(a[i] != b[cnt]) { b[++cnt] = a[i]; c[cnt] = ; }
else { c[cnt]++; if(c[cnt] == k) cnt--; }
}
if(!cnt) {puts(""); return ;}
for(i = ; i <= cnt; ++i) sum += c[i];
for(o = , i = ; i < cnt+-i; ++i) {//相当于两段序列之间
if(b[i] == b[cnt+-i] && c[i] + c[cnt+-i] == k) o += k;
else break;
}
if(i<cnt+-i) {
if(b[i] == b[cnt+-i] && c[i] + c[cnt+-i] > k) o += k;
ans = 1ll * sum * m - 1ll * o * (m-);
}
else {//剩一种数字
ans = 1ll * c[i] * m % k;
if(ans) ans += sum - c[i];//两端的数
}
printf("%lld\n", ans);
return ;
}
31ms
Codeforces Round #443 (Div. 2) 【A、B、C、D】的更多相关文章
- Codeforces Round #434 (Div. 2)【A、B、C、D】
Codeforces Round #434 (Div. 2) codeforces 858A. k-rounding[水] 题意:已知n和k,求n的最小倍数x,要求x后缀至少有k个0. 题解:答案就是 ...
- Codeforces Round #441 (Div. 2)【A、B、C、D】
Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...
- Codeforces Round #436 (Div. 2)【A、B、C、D、E】
Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...
- Codeforces Round #435 (Div. 2)【A、B、C、D】
//在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...
- Codeforces Round #440 (Div. 2)【A、B、C、E】
Codeforces Round #440 (Div. 2) codeforces 870 A. Search for Pretty Integers(水题) 题意:给两个数组,求一个最小的数包含两个 ...
- Codeforces Round #439 (Div. 2)【A、B、C、E】
Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...
- Codeforces Round #443 Div. 1
A:考虑每一位的改变情况,分为强制变为1.强制变为0.不变.反转四种,得到这个之后and一发or一发xor一发就行了. #include<iostream> #include<cst ...
- Codeforces Round #430 (Div. 2) 【A、B、C、D题】
[感谢牛老板对D题的指点OTZ] codeforces 842 A. Kirill And The Game[暴力] 给定a的范围[l,r],b的范围[x,y],问是否存在a/b等于k.直接暴力判断即 ...
- 【Codeforces Round #443 (Div. 2) A】Borya's Diagnosis
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟 [代码] #include <bits/stdc++.h> using namespace std; const ...
随机推荐
- C# 通过反射获取方法/类上的自定义特性
1.所有自定义属性都必须继承System.Attribute 2.自定义属性的类名称必须为 XXXXAttribute 即是已Attribute结尾 自定义属性QuickWebApi [Attribu ...
- python——高级特性
切片操作符 Python提供了切片(Slice)操作符,切片操作十分有用,可以通过切片轻松取出某一段数列.比如前10个数: #slice切片操作符 取前10个元素 L=list(range(0,100 ...
- 方法返回多个值参数Out使用的方法
string str; Console.WriteLine("请输入用户名"); string user = Console.ReadLine().ToString(); Cons ...
- [转]深入Java单例模式
文章从 https://blog.51cto.com/devbean/203501 转载 问题 : doble-check 实现的单例模式有什么缺点 线程安全的单例写法应该是怎么样的 概述 在G ...
- Cheatsheet: 2018 08.01 ~ 2018 10.31
Other Building the Ultimate Developer PC 3.0 - The Parts List for my new computer, IronHeart Face re ...
- cfE. Ehab and a component choosing problem(贪心)
题意 题目链接 给出一棵树,每个节点有权值,选出\(k\)个联通块,最大化 \[\frac{\sum_{i \in S} a_i}{k}\] Sol 结论:选出的\(k\)个联通块的大小是一样的且都等 ...
- Spring Boot 开发入门
准备工作 我们将使用Java开发一个简单的"Hello World" web应用,项目采用Maven进行构建 在开始前,打开终端检查下安装的Java和Maven版本是否可用: C: ...
- Cloud Computing Causing Digital Business Transformation
2015-04-13 Cloud Computing Causing Digital Business Transformation We hear all about the cloud, and ...
- C++学习笔记(8)----C++类的大小
C++类的大小 (i) 如下代码: #include<iostream> using namespace std; class CBase { }; class CDerive :publ ...
- 然之协同系统6.4.1 SQL注入之exp编写
前言 前面已经说明了 漏洞成因,这里介绍一下 exp 的编写. 正文 为了 getshell 或者是 任意文件下载, 我们需要修改 数据库中的 前缀sys_file 表, 所以我们的利用方式如下 使用 ...