In this post, the Covid Run CodeChef Solution is given. Question details : October Challenge 2020 Division 2 » Covid Run.
Covid Run Codechef Solution
#include<bits/stdc++.h> using namespace std; const int MOD=1000000007; #define ll long long #define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL); #define PB push_back int main() { Fastio; ll t; cin>>t; while(t--) { ll n,k,x,y; cin>>n>>k>>x>>y; ll val,t,flag=0; t=k; val=-1; while(val!=x) { val=(k+x)%n; k=k+t; if(val==y) { cout<<"YES"<<endl; flag=1; break; } } if(flag==0) cout<<"NO"<<endl; } } |
The solution of the above program is contributed by Vishal Vaibhab (IIT BHU). If you like TheCode11, then do follow us on Facebook, Twitter and Instagram.