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 ...
随机推荐
- shell通过ping检测整个网段IP的网络状态脚本
要实现Ping一个网段的所有IP,并检测网络连接状态是否正常,很多方法都可以实现,下面简单介绍两种,如下:脚本1#!/bin/sh# Ping网段所有IP# 2012/02/05ip=1 #通过修改初 ...
- [转]wxParse-微信小程序富文本解析组件
本文转自:https://github.com/icindy/wxParse 基本使用方法 Copy文件夹wxParse - wxParse/ -wxParse.js(必须存在) -html2json ...
- js弹出遮层
<script> var docEle = function () { return document.getElementById(arguments[0]) || false; } f ...
- golang类型转化
int 转 float mean:= float32(sum) float 转 int a := 5.0 b := int(a) string 转 int i,_ := strconv.At ...
- Java异步转同步
参考原文: <http://blog.csdn.net/veson__/article/details/53898890>
- 撩课-Python-每天5道面试题-第7天
一. 函数的返回值的概念,语法以及注意事项? 场景 当我们通过某个函数, 处理好数据之后, 想要拿到处理的结果 语法 def 函数(): 函数体 return 数据 注意事项 3.1 return 后 ...
- Spring Data JPA —— 快速入门
一.概述 JPA : Java Persistence API, Java持久层API,是JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中. Spring D ...
- js-js的运算
** js里面不区分整数和小数 var j = 123; alert(j/1000*1000); //在Java里面结果是0 //在js里面不区分整数和小数 123/1000 = 0.123 *100 ...
- JSTL总结摘要
一 概述 1.什么是JSTL? JSP Standard Taglib,一个定义了一系列标签的标签库,以取代在JSP页面中嵌套的java代码,经常与EL结合使用,使页面风格统一,维护方便. JSTL标 ...
- 关于 PHPMailer 邮件发送类的使用心得(含多文件上传)
This is important for send mail PHPMailer 核心文件 class.phpmailer.php class.phpmaileroauth.php class.ph ...