Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define ll long long
- using namespace std ;
- int main ()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t;
- cin >> t;
- while(t--){
- int a, b, q ;
- cin >> a >> b >> q ;
- vector<vector<ll> > v( q , vector<ll> (2));
- v.clear() ;
- for(int i = 0; i < q; i++){
- for(int j = 0; j < 2; j++){
- ll x ;
- cin >> x ;
- v[i][j] = x ;
- }
- ll ctr = 0 ;
- for(ll i = v[i][0] ; i <= v[i][1] ; i++){
- if( ((i%a)%b) != ((i%b)%a) ){
- ctr++ ;
- }
- }
- cout << ctr << " " ;
- }
- cout << "\n" ;
- }
- #ifndef ONLINE_JUDGE
- cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC * 100 << " sec\n";
- #endif
- return 0 ;
- }
Add Comment
Please, Sign In to add comment