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 ...
随机推荐
- 【很重要】优秀的常用的js库
http://lodashjs.com/docs/ 常用的各种工具库 sprintf 字符串格式 占位符替换等处理 devices.min.js
- Postgresql 连接更新
update dbo.m_role_fun a set role_code = b.rsc from (select rsc, fun_code from dbo.m_fun) b where a.f ...
- [转]玩转Windows服务系列——命令行管理Windows服务
本文转自:http://www.cnblogs.com/hbccdf/p/managewindowsservicewithcmd.html 说到Windows服务的管理就不得不说通过命令行的方式管理W ...
- Azure 应用服务中的 API 应用、ASP.NET 和 Swagger 入门
学习内容: 如何通过 Visual Studio 2015 中的内置工具在 Azure 应用服务中创建和部署 API 应用. 如何使用 Swashbuckle NuGet 包动态生成 Swagger ...
- [javaSE] 数据结构(二叉树-遍历与查找)
前序遍历:中,左,右 中序遍历:左,中,右 后序遍历:左,右,中 二叉树查找 从根节点进行比较,目标比根节点小,指针移动到左边 从根节点进行比较,目标比根节点大,指针移动到右边 /** * 前序遍历 ...
- SEO之网站被惩罚
- 【Android】利用回收机制创建ListView列表实现
MainActivity.java package com.glandroid.listviewdemo; import android.graphics.Color; import android. ...
- <Android 应用 之路> 百度地图API使用(4)
前言 百度地图的定位功能和基础地图功能是分开的,使用的是另外的jar包和so库文件,详情请关注官网: 百度定位SDK 配置 下载对应的jar包和so库,然后移动到lib目录下 AS中注意事项 sour ...
- c# copy类中值到另外一个对象中
贴图: 调用:
- Android学习笔记(2)----LocationManager的使用
今天使用Android的LocationManager制作了一款获取当前经纬坐标位置的软件. LocationManager获取的只是经纬坐标点,为了解析出当前经纬坐标点的实际位置,可以使用Googl ...