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 ...
随机推荐
- jsonp/ajax 自己的一些总结
data.json代码:[{"name": "张三", "age": 18}, {"name": "李四&qu ...
- 数据集DataSet
ADO.NET数据访问技术的一个突出的特点就是支持离线访问,而实现这种离线访问技术的核心就是DateSet对象,该对象通过将数据驻留在内存来实现离线访问. DataSet对象由一组DataTable对 ...
- ADO MFC SQL2000
对于初学VC的朋友来说,连接数据库其实是一件不容易的事情.记得我当时为了与数据库连接上,找了好多资料,上网看了好多文章,都没有解决这个问题.后 来,有个网友帮我解决了,我再次表示感谢.为了后来VC初学 ...
- Reddit: 只有独生子女才明白的事
duhvorced: 对我来说,恋爱成了件异常艰难的事. 我一直很羡慕有兄弟姐妹的人,特别是有异性兄弟姐妹的.他们能够在成长过程中明白异性对身体.友情的看法,知道他们如何处理不安全感,如何应对同龄人之 ...
- netty源代码编译_mac os
工作中会用到netty,有随手整理笔记的习惯,故学习整理下,之前看过了理论知识,接下来就看下源码了,先来编译下 个人 fork git:https://github.com/ending06/nett ...
- 使用dom4j写xml文件——源码
1 dom4j下载与配置 1.1 dom4j下载 请移步下载链接 1.2 maven依赖 <dependency> <groupId>org.dom4j</groupId ...
- 一图解析 React组件生命周期 (React Component Lifecycle)
React LifeCycle v1 参考官方文档作成 可放大 参考:https://reactjs.org/docs/react-component.html 数字补丁数字补丁数字补丁数字补丁数 ...
- VUE配置项结构
VUE配置项结构 config:项目的配置文件 index.js: 基础的配置信息 dev.env.js:开发环境配置信息 prod.env.js:线上环境配置信息 build: 项目打包所需要的内容 ...
- \n\r 转义字符
转义字符 意义 ASCII码值(十进制) \a 响铃(BEL) 007 \b 退格(BS) ,将当前位置移到前一列 008 \f 换页(FF),将当前位置移到下页开头 012 \n 换行(LF) ,将 ...
- wampserver 更改www目录
现在大家基本上开发php的有很大一部分都在用Wampserver,今天来讲讲怎么更改默认的www目录, 需要修改的文件有三个 apache2的配置文件 httpd.conf 和 Wampserver的 ...