Topic Link: Click to open the link
Test instructions
The amount of blood given n monsters, X ', y
The first person attacks X times per second, and the second attacks Y times per second.
Each attack causes a bit of damage to all surviving monsters.
Ask each monster who killed the last blow.
Idea: xy least common multiple inside a cycle section, first run out of this cycle section (while the attack caused 2 damage, just add 2 times in the cycle section both)
And then for every freak, just care about which attack point is in the Loop section.
#include <bits/stdc++.h>using namespace Std;const int maxn=2000010;int v[maxn];int main () { long long n,x,y; cin>>n>>x>>y; int sum=0; for (int i=1,j=1;i<=y&&j<=x;) { if (i*x<j*y) {v[++sum]=2;i++;continue;} if (i*x>j*y) {v[++sum]=1;j++;continue;} if (i*x==j*y) {v[++sum]=0;v[++sum]=0;i++;j++;continue;} } Long long m=x*y; for (int i=0;i<n;i++) { long long A; cin>>a; A=a%sum; if (v[a]==1) {cout<< "Vanya" <<endl;continue;} if (v[a]==2) {cout<< "Vova" <<endl;continue;} if (v[a]==0) {cout<< "Both" <<endl;continue;} } return 0;}
Codeforces 492D Vanya and computer Game cycle section finding patterns