-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathCVDRUN.cpp
49 lines (42 loc) · 849 Bytes
/
CVDRUN.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Question Link:
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<string.h>
# define mod 1000000007
using namespace std;
typedef long long int lli;
void solve()
{
//write your code here
int n,k,x,y;
cin >> n >> k >> x >> y;
vector<int>city;
city.push_back(x);
int val=(x+k)%n;
while(val!=x)
{
city.push_back(val);
val=(val+k)%n;
}
if(find(city.begin(),city.end(),y)!=city.end())
cout << "YES" << "\n";
else
cout << "NO" << "\n";
}
int main()
{
#ifndef ONLINE_JUDGE
freopen ("A:/c++/inputf.in", "r", stdin);
freopen ("A:/c++/outputf.in", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--)
{
solve();
}
return 0;
}