Codeforces Round #201 (Div. 2) 两道签到题(B, C)
来源:互联网 发布:淘宝个人申请企业店铺 编辑:程序博客网 时间:2024/05/16 05:26
这篇文章只是写给自己的,所有菜鸟老鸟都请无视
这是上星期五晚上的比赛
到现在才发两道让我窝火的水题(B, C)╮(╯▽╰)╭其实是被狠狠的打击了,本来都应该写出来的
首先是B - Fixed Points
思维不严密的我首先就忽略了所有序号上的值与序号一样的情况,坑爹的是pretest居然让我过,妈的干嘛不让我快活地挂掉
错误代码
#include <cstdio>#define MAX 100010int d[MAX];int main(){ int ans = 0; bool flag = true; bool flag_two = false; int n; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", d + i); if(d[i] >= n) {flag = false; break;} if(d[i] == i) ans++; else if(d[i] < i && d[d[i]] == i) flag_two = true; } if(!flag) printf("%d", 0); else { if(flag_two) { ans += 2; printf("%d", ans); } else { ans++; printf("%d", ans); } }}
比赛结束后然后改了一下就正确了哭
#include <cstdio>#define MAX 100010int d[MAX];int main(){ int ans = 0; bool flag = true; bool flag_two = false; bool flag_one = true; int n; scanf("%d", &n); for(int i = 0; i < n; i++) { scanf("%d", d + i); if(d[i] >= n) {flag = false; break;} if(d[i] == i) ans++; else if(d[i] < i && d[d[i]] == i) flag_two = true; if(d[i] != i) flag_one = false; } if(!flag) printf("%d", 0); else { if(flag_two) { ans += 2; printf("%d", ans); } else if(flag_one) { printf("%d", ans); } else { ans++; printf("%d", ans); } }}
然后更无语的是C题
这道题我连题目都没读懂要是读懂肯定能过
给你一些不同的数字,你选两个,把他们的差加入这对数字(前提是差不存在这堆数字中,如果存在那就不能选这两个数字,而且差后这两个数字不会被移去)
思路:求出公约数,所有其他数都能通过最大数和公约数得到 所以游戏次数 = (最大数 / 公约数) - (一开始给出的数字个数)
真不知道当时在想什么我去,各种错误理解
后来看懂了拍了就过了
#include <cstdio>int a[120];int gcd(int, int);int main(){ int n; scanf("%d", &n);scanf("%d", &a[0]); int max = a[0]; int t = a[0]; for(int i = 1; i < n; i++) { scanf("%d", &a[i]); t = gcd(t, a[i]); if(a[i] > max) max = a[i]; } int sum = max / t - n; if(sum % 2) printf("Alice"); else printf("Bob");}int gcd(int a, int b){ if(b == 0) return a; else return gcd(b, a % b);}
后面两道dp现在还没搞懂
- Codeforces Round #201 (Div. 2) 两道签到题(B, C)
- Codeforces Round #430 (Div. 2) 签到题
- Codeforces Round #243 (Div. 2) B C
- Codeforces Round #266 (Div. 2) B & C
- Codeforces Round #258 (Div. 2) B C
- Codeforces Round #307 (Div. 2) B C
- Codeforces Round #407 (Div. 2) B+C!
- Codeforces Round #431 (Div. 2) B, C
- Codeforces Round #448 (Div. 2) B,C,
- Codeforces Round #447 (Div. 2) B,C
- Codeforces Round #449 (Div. 2) (B、C)
- Codeforces Round #290 (Div. 2) B题 C题
- Codeforces Round #296 (Div. 2) B C题
- Codeforces Round #201 (Div. 2)A、B
- Codeforces Round #169 (Div. 2) B题
- Codeforces Round #188 (Div. 2) B题
- Codeforces Round #218 (Div. 2) B题
- Codeforces Round #238 (Div. 2) B题
- 织梦DEDECMS {dede:arclist},{dede:list}获取附加表字段内容
- 2014年阿里巴巴9月14号笔试题
- 安卓开发42:lauchMode Activity的启动模式
- QT 编码格式问题
- 常见需求调查方式
- Codeforces Round #201 (Div. 2) 两道签到题(B, C)
- AS3数字取整
- shell cmd
- 深刻理解Java编程的7个例子
- Kindle阅读软件
- PS流格式
- JDK1.6安装与环境变量设置详细图解
- java获取类中的属性和值
- 前、中、后缀表达式