Guest User

1342C

a guest
Apr 27th, 2020
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std ;
  4. int main ()
  5. {  
  6.     ios_base::sync_with_stdio(false);
  7.     cin.tie(NULL);
  8.    int t;
  9.    cin >> t;
  10.    while(t--){
  11.       int a, b, q ;
  12.       cin >> a >> b >> q ;
  13.       vector<vector<ll> > v( q , vector<ll> (2));
  14.       v.clear() ;
  15.       for(int i = 0; i < q; i++){
  16.          for(int j = 0; j < 2; j++){
  17.             ll x ;
  18.             cin >> x ;
  19.             v[i][j] = x ;
  20.          }
  21.          ll ctr = 0 ;
  22.          for(ll i = v[i][0] ; i <= v[i][1] ; i++){
  23.             if( ((i%a)%b) != ((i%b)%a) ){
  24.                ctr++ ;
  25.             }
  26.          }
  27.       cout << ctr << " " ;
  28.       }
  29.    
  30.    cout << "\n" ;
  31.    }
  32.  
  33.    #ifndef ONLINE_JUDGE
  34.    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC * 100 << " sec\n";
  35.     #endif
  36.    
  37.     return 0 ;
  38. }
Add Comment
Please, Sign In to add comment