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】的更多相关文章

  1. 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. 题解:答案就是 ...

  2. Codeforces Round #441 (Div. 2)【A、B、C、D】

    Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...

  3. Codeforces Round #436 (Div. 2)【A、B、C、D、E】

    Codeforces Round #436 (Div. 2) 敲出一身冷汗...感觉自己宛如智障:( codeforces 864 A. Fair Game[水] 题意:已知n为偶数,有n张卡片,每张 ...

  4. Codeforces Round #435 (Div. 2)【A、B、C、D】

    //在我对着D题发呆的时候,柴神秒掉了D题并说:这个D感觉比C题简单呀!,,我:[哭.jpg](逃 Codeforces Round #435 (Div. 2) codeforces 862 A. M ...

  5. Codeforces Round #440 (Div. 2)【A、B、C、E】

    Codeforces Round #440 (Div. 2) codeforces 870 A. Search for Pretty Integers(水题) 题意:给两个数组,求一个最小的数包含两个 ...

  6. Codeforces Round #439 (Div. 2)【A、B、C、E】

    Codeforces Round #439 (Div. 2) codeforces 869 A. The Artful Expedient 看不透( #include<cstdio> in ...

  7. Codeforces Round #443 Div. 1

    A:考虑每一位的改变情况,分为强制变为1.强制变为0.不变.反转四种,得到这个之后and一发or一发xor一发就行了. #include<iostream> #include<cst ...

  8. 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.直接暴力判断即 ...

  9. 【Codeforces Round #443 (Div. 2) A】Borya's Diagnosis

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟 [代码] #include <bits/stdc++.h> using namespace std; const ...

随机推荐

  1. C#、OC递归锁

    做ios也有1年了,C#的东西有些都忘记了,最近几天也打算重温一下,不能学了ios把C#给抛弃了,两者都要抓,一精多专.目前C#只是重温,重点是web这块.今天主要是想起了之前做过的面试题,虽然题比较 ...

  2. [译]用R语言做挖掘数据《二》

    数据探索 一.实验说明 1. 环境登录 无需密码自动登录,系统用户名shiyanlou,密码shiyanlou 2. 环境介绍 本实验环境采用带桌面的Ubuntu Linux环境,实验中会用到程序: ...

  3. DES c#加密后java解密

    public static String byteArr2HexStr(byte[] bytIn) { StringBuilder builder = new StringBuilder(); for ...

  4. nodejs应用离线安装部署、卸载

    公司写的文档,直接粘贴过来了: 本文档提供node应用一键安装.部署.卸载说明,包含对应脚本文件 默认版本:1.nodejs:v6.11.2.linux-x642.全局npm包:pm2.supervi ...

  5. 百度搜索URL参数含义

    序号 参数 含义 1 tn 搜索框所属网站.比如 tn=sitehao123,就是 http://www.hao123.com/ 左上那个搜索框(指通过什么方式到达百度首页搜索界面;) 2 s?wd ...

  6. Java学习--jsp内置对象

    九个内置对象,其中Out,request,response,session,application常用 get与post区别: request对象: response对象: 请求转发与请求重定向的区别 ...

  7. 一、Java多线程基础

    一.简介 1.操作系统 在早起的裸机时代,计算机非常地昂贵,而且也没有操作系统的概念,计算机从头到尾只能执行一个程序.如果程序在执行一个耗时的操作,那么在这个过程中,计算机就有大量的资源闲置在那里,这 ...

  8. csharp:SQLite and Access using C# code read data

    SQLite sql script: CREATE TABLE BookKindList ( BookKindID INTEGER PRIMARY KEY AUTOINCREMENT, BookKin ...

  9. CNN中tensorboard数据可视化

    1.CNN_my_test.py import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data ...

  10. Ueditor更改编辑框样式

    1.在ueditor.all.min.js文件中查找“ueditor.css”,找到位置后更改css文件,或在原文件中更改