Covid Run Problem Code: CVDRUN Codechef Solution

 #include <bits/stdc++.h>
using namespace std;
int main() {  
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t;
  cin>>t;
  while(t--){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    int a[1001]={0};
    a[x]=1;
    int i=x+k;
    i%=n;
    while(!a[i]){
      a[i]=1;
      i+=k;
      i%=n;
    }
    if(a[y])cout<<"YES";
    else cout<<"NO";
    cout<<"\n";
  }
}

Comments