codeforces 492D Vanya and Computer Game(额。。。数学题?水题吧)
2014-12-04 17:35
495 查看
传送门:点击打开链接
题目大意:
有2个人在打怪,攻击频率分别是x,y。小怪有num点血。问死的时候是谁打死的。如果同时出手 输出Both。
解题思路:
在一秒内考虑这个问题(一秒是循环节)。
假设攻击时刻的分母x*y。那么容易得到每个人的攻击时刻(在一秒内)。
然后如果有一个时刻有重复。那么肯定是2个人同时在打。
排个序就好了。
这是D题么。。。我觉得最多是C题难度,吐槽一下。。。
题目大意:
有2个人在打怪,攻击频率分别是x,y。小怪有num点血。问死的时候是谁打死的。如果同时出手 输出Both。
解题思路:
在一秒内考虑这个问题(一秒是循环节)。
假设攻击时刻的分母x*y。那么容易得到每个人的攻击时刻(在一秒内)。
然后如果有一个时刻有重复。那么肯定是2个人同时在打。
排个序就好了。
这是D题么。。。我觉得最多是C题难度,吐槽一下。。。
#include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <cstring> using namespace std; struct Node { long long num; int team; bool operator < (const Node& b)const{ return num < b.num; } }a[2020202]; int cnt; void init(long long x,long long y) { cnt = 0; for(int i = 1;i <= x;i++){ a[cnt++] = (Node){(long long)(y*i),1}; } for(int i = 1;i <= y;i++){ a[cnt++] = (Node){(long long)(x*i),2}; } } int main() { int n; long long x,y; cin >> n >> x >>y; init(x,y); sort(a,a+cnt); for(int i = 1;i <= n;i++){ long long times; scanf("%I64d",×); times--; times = times%(x+y); if(times+1 < cnt && a[times].num == a[times+1].num){ printf("Both\n"); continue; } if(times != 0 && a[times].num == a[times-1].num){ printf("Both\n"); continue; } if(a[times].team == 1){ printf("Vanya\n"); } else{ printf("Vova\n"); } } return 0; }
相关文章推荐
- Codeforces 478A Initial Bet(数学水题)
- CodeForces 638 A Home Numbers(数学,水题)
- Codeforces-----140A---New Year Table---数学水题
- Codeforces-----614A---Link/Cut Tree---数学水题
- codeforces 4A Watermelon(数学水题)
- CodeForces--621A--Wet Shark and Odd and Even(数学水题)
- codeforces 50A Domino piling(数学水题)
- CodeForces--621A--Wet Shark and Odd and Even(数学水题)
- CodeForces - 151A Soft Drinking (数学水题)
- CodeForces 706A Beru-taxi (数学计算,水题)
- CodeForces 628B New Skateboard-数学水题
- Codeforces--660A--Co-prime Array(数学水题)
- HDU1977 Consecutive sum II【数学计算+水题】
- CodeForces 229 C.Triangles(组合数学)
- CodeForces 272 D.Dima and Two Sequences(组合数学)
- Codeforces 628B New Skateboard【数学】
- CodeForces 366A Dima and Guards(结构体,数学)
- CodeForces 319 A.Malek Dance Club(组合数学)
- Codeforces 633D Fibonacci-ish 数学+暴力
- CodeForces 733A Grasshopper And the String(水题)