Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<algorithm>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- for(int w=0;w<t;w++){
- unsigned long long n,k,a,b,count1=0,count2=0;
- cin>>n>>k;
- unsigned long long ub=(n*n)+(2*n);
- ub=min(ub,k-1);
- for(a=n+1;a<=ub;a++){
- unsigned long long r=a/(a-n);
- r=r+1ULL;
- unsigned long long u_bound=(n*((r*(a-n))-1ULL))/(((r-1ULL)*a)-(r*n));
- u_bound=min(u_bound,k-1);
- for(b=a;b<=u_bound;b++){
- unsigned long long div=((a*b)-n);
- unsigned long long divisor=(a-n)*(b-n);
- unsigned long long rem=div%divisor;
- if((rem==0ULL)&&(a==b)){
- count1++;
- }
- if((rem==0ULL)&&(a!=b)){
- count2++;
- }
- }
- }
- unsigned long long count=(2ULL * count2) + count1;
- cout<<count<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement