Codeforces Round #426 (Div. 2) (solve 3 of 5)
来源:互联网 发布:点击精灵淘宝版 编辑:程序博客网 时间:2024/06/17 01:30
这一场血崩了,A题交太快WA了,B题读错题WA了,C题没特判WA了..orz..
A. The Useless Toy【模拟】
题意:
1.给你2个符号和1个数字,代表初始状态、终止状态、旋转次数。
2.保证输入数据正确,问你输入的旋转是顺时针、逆时针还是不能确定。
思路:
暴力模拟。
代码:
#include <bits/stdc++.h>using namespace std;typedef pair<int,int>pii;typedef long long LL;int main() { char a, b; char op[] = {'v', '<', '^', '>'}; cin >> a >> b; int n; cin >> n; n %= 4; int idx; for(idx = 0; idx < 4; idx++) if(op[idx] == a) break; int sum = 0; //模拟顺时针 while(1) { if(op[idx] == b) break; idx = (idx + 1) % 4; //循环 sum ++; } if(sum == 2 || sum == 0) puts("undefined"); else if(sum == n) puts("cw"); else puts("ccw");}
B. The Festive Evening【模拟】
题意:
1.给你n个客人和k个守卫,城堡最多有26个门,用ABC…Z代表。
2.按时间顺序给你n个客人进的门。
3.守卫必须在每个门的客人到来前开门,且在最后一个通过该门的客人离开时才能关门。
4.为了满足3,问你守卫是否够数。
思路:
1.记录每个门的客人人数。
2.按时间顺序模拟,如代码注释。
代码:
#include <bits/stdc++.h>using namespace std;string s;int mp[500];bool vis[500];int main() { int n, k; memset(vis, false, sizeof(vis)); memset(mp, 0, sizeof(mp)); cin >> n >> k >> s; //记录每个门的人数 for(int i = 0; i < s.size(); ++ i) mp[s[i]] ++; for(int i = 0; i < s.size(); ++ i) { mp[s[i]] --; //第一次经过 if(vis[s[i]] == false) { vis[s[i]] = true, k--; if(k < 0) return 0 * puts("YES"); } //如果时最后一个进入该门的人,则守卫又空出一个 if(mp[s[i]] == 0) k++; } puts("NO");}
C. The Meaningless Game【数学】
题意:
1.
2.两个人,初始成绩都为
3.每次选一个数k,其中一人乘以
4.问最终能否匹配
思路:
1.每一次选
2.所以只要判断最终成绩成绩能否开3次方,且能整除
代码:
#include <bits/stdc++.h>using namespace std;typedef long long LL;int main() { int n; scanf("%d", &n); long long a, b; while(n--) { scanf("%I64d %I64d", &a, &b); LL t = a * b; LL tp = pow(t, 1.0/3); bool f = false; //防止精度丢失 for(LL i = tp - 2; i <= tp + 2; i++) { if(i * i * i == t && a % i == 0 && b % i == 0) { puts("Yes"); f = true; break; } } if(f == false) puts("No"); }}
阅读全文
0 0
- Codeforces Round #426 (Div. 2) (solve 3 of 5)
- Codeforces Round #401 (Div. 2) (solve 4 of 5)
- Codeforces Round #427 (Div. 2) (solve 5 / 6)
- Codeforces Round #425 (Div. 2) (solve 4)
- Codeforces Round #337 (Div. 2)(3/5)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #426 (Div. 2)
- Codeforces Round #188 (Div. 2) B. Strings of Power
- Codeforces Round #105 (Div. 2) D. Bag of mice
- Codeforces Round #209 (Div. 2) D. Pair of Numbers
- Codeforces Round #209 (Div. 2) D. Pair of Numbers
- Codeforces Round #209 (Div. 2), problem: (D) Pair of Numbers
- Codeforces Round #209 (Div. 2) D. Pair of Numbers
- Codeforces Round #230 (Div. 2) D - Tower of Hanoi
- Codeforces Round #266 (Div. 2) C Number of Ways
- 使用String的split方法你需要注意的地方
- springmvc中 继承MultiActionController 3种
- 8月15日云栖精选夜读:阿里云新一代关系型数据库 PolarDB 剖析
- eclipse 当中,两种添加插件的方法 .
- Swift 4.0 新特性
- Codeforces Round #426 (Div. 2) (solve 3 of 5)
- H5---面试题九
- 顶级芯片制造商为扩展全球业务承保220亿美金
- HDU 2017 多校联合训练赛7 1008 6127 Hard challenge (重载运算符)
- 2016 清华 计算机 考研 经验 总结
- 第一期阿里云高校工作坊申办启动
- 下载美国气候数据中心地址
- MySQL之——如何防止人为误操作MySQL数据库
- linux grep命令详解