Advertisement
code_hacker

Untitled

Sep 7th, 2011
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<cstdio>
  4. #include<cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int t;
  11.     cin>>t;
  12.     for(int w=0;w<t;w++){
  13.         unsigned long long n,k;
  14.         cin>>n>>k;
  15.         unsigned long long i,j;
  16.         unsigned long long count1=0ULL;
  17.         unsigned long long count2=0ULL;
  18.         unsigned long long x=3ULL*n;
  19.         unsigned long long y=4ULL*n*n;
  20.         x=min(x,k-n);
  21.         y=min(y,k-n);
  22.        
  23.         for(i=1ULL;i<x;i++){
  24.             for(j=i;j<y;j++){
  25.                 unsigned long long q=i*j;
  26.                 unsigned long long rem=((n%q)*((i+j+n-1)%q))%q;
  27.                 if((rem==0ULL)&&(i==j))
  28.                         count1++;
  29.                 if((rem==0ULL)&&(i!=j))
  30.                         count2++;
  31.                
  32.             }
  33.         }
  34.        
  35.         unsigned long long count=count1+(2ULL * count2);
  36.        
  37.         cout<<count<<"\n";     
  38.        
  39.     }
  40.    
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement