#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define wzh(x) cerr<<#x<<'='<<x<<endl;
int a[N],cnt,p[N],mu[N],mn[N];
LL phi[N];
void P(){
phi[1]=mu[1]=1;
for(int i=2;i<N;i++){
if(!p[i])a[++cnt]=i,mu[i]=-1,phi[i]=i-1,mn[i]=i;
for(int j=1;j<=cnt&&1ll*a[j]*i<N;j++){
p[a[j]*i]=1;
if(i%a[j]==0){
mn[i*a[j]]=a[j];
mu[i*a[j]]=0;
phi[i*a[j]]=a[j]*phi[i];
break;
}
mu[a[j]*i]=-mu[i];
phi[i*a[j]]=phi[i]*phi[a[j]];
}
}
}
LL sz=1;
LL get_pre(int x){
vector<pair<int,int>>v;
for(int i=1;i<=cnt&&1ll*a[i]*a[i]<=x;i++){
if(x%a[i]==0){
int res=0;
while(x%a[i]==0){
res++;
x/=a[i];
}
sz*=res+1;
v.emplace_back(a[i],res);
}
}
if(x>1)v.emplace_back(x,1),sz*=2;
LL tot=1;
for(auto k:v){
LL pre=tot,res=0,now=1;
for(int i=0;i<=k.se;i++,now*=k.fi){
res+=pre*(now*now);
}
tot=res;
}
return tot;
}
int x;
int main() {
ios::sync_with_stdio(false);
P();
int t;
for(cin>>t;t;t--){
cin>>x;sz=1;
LL X=get_pre(x);
cout<<X-sz*x<<'\n';
}
return 0;
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交