Codeforces Round #412 (Div. 2)
来源:互联网 发布:scp 指定端口 编辑:程序博客网 时间:2024/06/05 15:02
链接: http://codeforces.com/contest/807
A
题意:太水了,按着题目要求写就行,分好情况。
#include <iostream>#include <algorithm>#include <cstring>#include <cmath>#include <cstdio>#include "stdio.h"#include <stdio.h>using namespace std;int rating[1005][2];int main() { int n; scanf("%d", &n); int flag = 0; for (int i = 0; i < n; i++) { scanf("%d%d", &rating[i][0], &rating[i][1]); if (rating[i][0] != rating[i][1]) flag = 1; } int i; if (flag == 1) { printf("rated\n"); } else { for (i = 0; i < n - 1; i++) { if (rating[i][0] < rating[i + 1][0]) { printf("unrated\n"); break; } } if (i == n - 1) printf("maybe\n"); } return 0;}
C
题意:在OJ上,一个人AC了x道题目,提交了y道,所以目前AC率是x/y。求还需要提交多少题,才可以使AC率达到p/q。(要注意,如果x/y>p/q,需要提交错误的答案,以使分母变大。当然,即使x/y
#include <iostream>#include <algorithm>#include <cstring>#include <stdio.h>#include <cmath>using namespace std;int main(){ int t; long long x, y, p, q; scanf("%d", &t); while (t--){ scanf("%I64d%I64d%I64d%I64d", &x, &y, &p, &q); if (p == 0){ if (x == 0) printf("0\n"); else printf("-1\n"); continue; } if (p == 1 && q == 1 && x != y){ printf("-1\n"); continue; } /*if (x*q < y*p){ //这里是错误的,即使x*q<y*p,也不一定只交正确提交就能达到p/q。 printf("%I64d\n", (q*x - p*y) / (p - q)); }*/ if (x*q == y*p){ printf("0\n"); } else{ //这一步是重点,需要推导 long long h1 = ceil(x*1.0 / p); //因为涉及除法,有可能会产生精度问题。 //ceil意思是天花板,所以是向上取整。floor意思是地板,所以是向下取整。 long long h2 = ceil(y*1.0 / q); long long h3 = ceil((y - x)*1.0 / (q - p)); long long k = max(h1, max(h2, h3)); //k为同时满足三个条件的最小值 printf("%I64d\n", k*q - y); } } return 0;}
阅读全文
0 0
- Codeforces Round #412 (Div. 2)
- Codeforces Round #412 ( Div. 2)A+B
- Codeforces Round #412 ( Div. 2) C
- Codeforces Round #412 (Div.2) ABC
- [刷题]Codeforces Round #412(Div. 2)
- Codeforces Round #412 (Div. 2)(Codeforces 807 ABCDE)
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #105 (Div. 2)
- Codeforces Round #107 (Div. 2)
- Codeforces Round #108 (Div. 2)
- Codeforces Round #110 (Div. 2)
- Codeforces Round #122 (Div. 2)
- Codeforces Round #121 (Div. 2)
- Codeforces Round #124 (Div. 2)
- 权限,网络请求,判断,XlistVIew的依赖
- Wooden Sticks HDU
- mybatis常见问题处理:批量操作,传递多个参数,like语句写法等等
- 微信一次性订阅消息
- react-router HashRouter和BrowserRouter的使用
- Codeforces Round #412 (Div. 2)
- ios 图片由小到大和由大到小的渐进效果
- linux下安装squid
- Interesting Calculator UVA
- vim使用手册
- Qt的XML文件处理
- mac 终端连接到服务器
- Guava Table<R,C,V>
- java8之lambda表达式