Codeforces Round #412 (Div. 2)ABCD
tourist的剧毒contest,题干长到让人不想做...
A.看不太懂题意直接看下面input output note
n组里有两数不一样的一组就rated
否则单调不增为maybe,否则unrated
B.题干给出了长度为25的数列的构造规则
i := (x div 50) mod 475
repeat 25 times:
i := (i * 96 + 42) mod 475
print (26 + i)
然后我们就需要通过几次成功和不成功的hack来调整读入的x
成功 x + 100,失败 x - 50
使得构造出来的数列中包含p,同时保证 x >= y
数据范围很小,可以直接暴力枚举
#include <bits/stdc++.h> #define rep(i, j, k) for(int i = j;i <= k;i ++) #define rev(i, j, k) for(int i = j;i >= k;i --) using namespace std; typedef long long ll; int p; bool ok(int x) {
int i = x / % ;
rep(j, , ) {
i = i* + , i %= ;
if(i + == p) return ;
}
return ;
} int main() {
ios::sync_with_stdio(false);
int x, y, ans = ;
cin >> p >> x >> y;
for(int i = x;i >= y;i -= )
if(ok(i)) {
ans = ;
break;
}
for(int i = x + , j = ;j < ans;i += , j = (i + - x) / ) {
if(ok(i)) {
ans = j;
break;
}
}
cout << ans;
return ;
}
C.某人在cf上,通过/提交 = x/y,他想再提交几次使 通过/提交 = p/q
求最少再提交多少次(保证p/q这个分数最简
设提交b次可行 ,则有 y + b = kq , x <= kp <= x + b
把 b = kq - y 带入右侧不等式,则有
k >= max( ceil(x / p), ceil((y - x)/(q - p)) )
显然满足此条件的 k 均可行,所以
min_k = max( ceil(x / p), ceil((y - x)/(q - p)) )
answer = min_k * q - y
#include <cstdio> typedef long long ll; ll max(ll x, ll y) {
return x > y ? x : y;
} int main() {
int n;
ll x, y, p, q, k, k1, k2;
scanf("%d", &n);
while(n --) {
scanf("%I64d %I64d %I64d %I64d", &x, &y, &p, &q);
if(p == q) {
if(x == y) puts("");
else puts("-1");
}
else if(p == ) {
if(x == ) puts("");
else puts("-1");
}
else {
k1 = x / p + (x % p != );
k2 = (y - x) / (q - p) + ((y - x) % (q - p) != );
printf("%I64d\n", max(k1, k2) * q - y);
}
}
return ;
}
这道题我写的正解一开始cin就一直WA
改成scanf就对了???贴出 wrong answer 的代码
#include <bits/stdc++.h> #define rep(i, j, k) for(int i = j;i <= k;i ++) #define rev(i, j, k) for(int i = j;i >= k;i --) using namespace std; typedef long long ll; int main() {
ios::sync_with_stdio(false);
int n;
ll x, y, p, q, k;
cin >> n;
while(n --) {
cin >> x >> y >> p >> q;
if(x * q == p * y) puts("");
else if(x * q < p * y) {
if(p == q) puts("-1");
else {
k = max((x + p - ) / p, (y - x + q - p - ) / (q - p));
cout <<k * q - y << endl;
}
}
else {
if(p == ) puts("-1");
else {
k = max((x + p - ) / p, (y - x + q - p - ) / (q - p));
cout << k * q - y << endl;
}
}
}
return ;
}
D.一场比赛2h,5题
给出某个题的总分与 通过人数/总人数 的关系
以及在第 i 分钟通过的人获得的分数为 max_point * (1 - i / 250)
输入包含 n 个人每个题通过的时间
其中选手1可以通过开小号来作弊
他开小号可以提交正确或错误代码
但不可能提交他自己都没过的题目的正确代码
问他最少开多少个小号可以使自己的分数 > 选手2的分数
显然一个贪心策略是(以下时间长短均对比选手2而言)
如果在某个题上选手1时间短
那么他肯定让小号都交错,提高该题分数
如果用的时间长但还是过了肯定小号都交对降低该题分数
没过的话没得选择
加粗部分使我们不能二分!
小号越多对选手1越有利吗?不!
1有个题没过但2过了
继续增加小号反而可能使该题分值增加,不利于1!
但是我们二分的时候发现R = 120 × 32(来自上面表中的 1/32
于是直接从 0 枚举到 5k 就ok...
#include <bits/stdc++.h> #define rep(i, j, k) for(int i = j;i <= k;i ++) #define rev(i, j, k) for(int i = j;i >= k;i --) using namespace std; typedef long long ll; int n; int a[][], c[]; bool judge(int x) {
int s = , t;
rep(i, , ) {
if(a[][i] == a[][i]) continue;
else {
if(a[][i] > a[][i] && a[][i] != ) t = x;
else t = ;
if( * (t + c[i]) > (x + n)) s += * (a[][i] - a[][i]);
else if( * (t + c[i]) > (x + n)) s += * (a[][i] - a[][i]);
else if( * (t + c[i]) > (x + n)) s += * (a[][i] - a[][i]);
else if( * (t + c[i]) > (x + n)) s += * (a[][i] - a[][i]);
else if( * (t + c[i]) > (x + n)) s += * (a[][i] - a[][i]);
else s += * (a[][i] - a[][i]);
}
}
return s > ;
} int main() {
ios::sync_with_stdio(false);
cin >> n;
rep(i, , n) rep(j, , ) {
cin >> a[i][j];
if(a[i][j] == -) a[i][j] = ;
else c[j] ++;
}
rep(i, , )
if(judge(i)) {
cout << i;
return ;
}
puts("-1");
return ;
}
Codeforces Round #412 (Div. 2)ABCD的更多相关文章
- Codeforces Round #258 (Div. 2)[ABCD]
Codeforces Round #258 (Div. 2)[ABCD] ACM 题目地址:Codeforces Round #258 (Div. 2) A - Game With Sticks 题意 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- Codeforces Round#412 Div.2
A. Is it rated? 题面 Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codefo ...
- Codeforces Round #412 Div. 2 第一场翻水水
大半夜呆在机房做题,我只感觉智商严重下降,今天我脑子可能不太正常 A. Is it rated? time limit per test 2 seconds memory limit per test ...
- Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring
D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #449 (Div. 2)ABCD
又掉分了0 0. A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Codeforces Round #143 (Div. 2) (ABCD 思维场)
题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...
- Codeforces Round #248 (Div. 2) (ABCD解决问题的方法)
比赛链接:http://codeforces.com/contest/433 A. Kitahara Haruki's Gift time limit per test:1 second memory ...
随机推荐
- java问题解读,String类为什么是final的
一.理解final 望文生义,final意为“最终的,最后的”,我理解为“不能被改变的”,它可以修饰类.变量和方法. 所以我是否可以理解为被它所修饰的类.变量和方法都不能被改变呢?答案是”是“,因为有 ...
- JSP-Runoob:JSP 语法
ylbtech-JSP-Runoob:JSP 语法 1.返回顶部 1. JSP 语法 本小节将会简单地介绍一下JSP开发中的基础语法. 脚本程序 脚本程序可以包含任意量的Java语句.变量.方法或表达 ...
- 特征变化--->标签到向量的转换(OneHotEncoder)
一.One-Hot Encoding One-Hot编码,又称为一位有效编码,主要是采用位状态寄存器来对个状态进行编码,每个状态都由他独立的寄存器位,并且在任意时候只有一位有效. 在实 ...
- Android之NDK开发(转载)
http://www.cnblogs.com/devinzhang/archive/2012/02/29/2373729.html 一.NDK产生的背景 Android平台从诞生起,就已经支持C.C+ ...
- eclipse的快捷键---调试
1:查看类或接口的方法 Ctrl+T 2:debug调试查看信息 Ctrl+Shift+i 3:debug调试快捷键 (1):F11好像是重新运行debug. (2):F8直接输出结果.(3):F5单 ...
- AngularJS过滤器filter-保留小数-渲染页面-小数点-$filter
AngularJS 保留小数 默认是保留3位 固定的套路是 {{deom | number:4}} 意思就是保留小数点 的后四位 在渲染页面的时候 加入这儿个代码 用来精确浮点数,指定小数点 ...
- [Swift通天遁地]八、媒体与动画-(2)实现视频文件的播放和画中画
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- mysql中判断记录是否存在方法
以下这个方法是我推荐的. sql语句:select 1 from tablename where col = col limit 1; 然后读取语句执行所影响的行数. 当然这里limit 1很重要.这 ...
- ios TextField 不被键盘遮住
首先放一个scrollView窗口,将Scroll View视图占整个屏幕. 向Scroll View 添加TextField 控件. 首先,ViewController.h 代码如下; #i ...
- mysql复制数据
前言:由于工作需要,我要造大量数据,最好的方法是直接copy已有的数据,改其中一些值即可.操作的表有主键,且自增,AUTO_INCREMENT 按照以往的经验无外乎: 类别一. 如果两张张表(导出表和 ...