forked from Dverma1650/Hacktoberfest_2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
code chef oct challenge (covid run)
66 lines (65 loc) · 1.35 KB
/
code chef oct challenge (covid run)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repF(i,a,n) for(int i = (a); i <= (n); ++i)
#define repB(i,a,n) for(int i = (a); i >= (n); --i)
#define umii unordered_map<int,int>
#define umll unordered_map<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define F first
#define S second
#define seti set<int>
#define setl set<ll>
#define pb push_back
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define dbV(arr) cout << #arr << "=[ "; \
for(auto i:arr) cout << i << " "; cout << "]\n";
#define MOD 1000000007
#define all(z) z.begin(),z.end()
using namespace std;
using ll = long long;
vector<vi> tree;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t; cin >> t;
while (t--) {
ll n, x, y, k;
cin >> n >> k >> x >> y;
ll val[n] = {0}, temp = 0;
while (1) {
if (val[x]) {
temp = 1 ;
break;
}
val[x]++;
x = (x + k) % n;
if (val[y]) {
temp = 2;
break;
}
}
if (k == 0 || k == n) {
if (x == y) {
cout << "YES\n";
}
else {
cout << "NO\n";
}
}
else if (temp == 2) {
cout << "YES\n";
}
else {
cout << "NO\n";
}
}
return 0;
}