rt,用的春测T2的某种高妙做法写的,但是出现了弱智的精度问题——
wrong answer 15625th numbers differ - expected: '1001003179', found: '1001003180'
怎么整呢——(已绝望)
/*
省略超长的预编译指令
*/
ll n,k;
ll p[N];
ll q_pow(ll a,ll b){
ll res=1;
for(;b;b>>=1){
if(b&1) res=res*a;
a=a*a;
}
return res;
}
ll _sqrt(ll a,ll b){ //用于求a的b次根,别提二分了,精度更加离谱
if(b==1) return a;
// ll r=q_pow(2,(60/b)+1),l=1;
// while(l<=r){
// int mid=(l+r)>>1;
// if(q_pow(mid,b)<=a) l=mid+1;
// else r=mid-1;
// }
// return r;
return pow(a,(long double)1.0/b);
}
int check(ll x){
for(int i=2;i<=60;i++){
ll res=_sqrt(x,i);
if(q_pow(res,i)==x){
return 1;
}
}
return 0;
}
signed main(){
p[2]=1;
for(int i=3;i<=60;i++){
p[i]=1;
for(int j=2;j<=i-1;j++){
if(i%j==0) p[i]-=p[j];
}
}
int T;
cin(T);
while(T--){
ll a,b;
cin(a,b);
if(a==b){
puts("1");
continue;
}
ll ans1=1,ans2=1;
for(int i=2;i<=60;i++){
ans1+=p[i]*(_sqrt(a,i)-1);
ans2+=p[i]*(_sqrt(b,i)-1);
}
print(ans2-ans1+check(a));
putchar('\n');
}
return 0;
}