#include <iostream>
#include <stdio.h>
#include <map>
using namespace std;
typedef long long LL;
const int MAXN = 10001;
const LL M = 1000000007;
int factor[10001],cnt;
LL n,res;
inline LL fix(LL val){
return (val+M)%M;
}
inline LL pow4(LL val){
val = fix(val*val);
val = fix(val*val);
return val;
}
LL cal(LL val){
int i,a=2,b=3,c=5;
LL t[4];
t[0]=val,t[1]=val+1,t[2]=val*2+1,t[3]=3*val*val+3*val-1;
for(i=0;i<4;i++){
if(t[i]%a==0) t[i]/=a,a=1;
if(t[i]%b==0) t[i]/=b,b=1;
if(t[i]%c==0) t[i]/=c,c=1;
}
for(i=1;i<4;i++)
t[0] = fix(t[0]*fix(t[i]));//妈的,这里以为t[i]之间相乘可以的。。竟然t[3]是两次方的,找了一晚上的伤不起啊
return t[0];
}
void init(){
LL tn = n;
int i;
for(i=2;i*i<=tn;i++){
if(tn%i==0){
factor[cnt++] = i;
while(tn%i==0) tn/=i;
}
}
if(tn!=1 ) factor[cnt++] = tn;
}
void solve(LL val,int idx,int flag,bool OK){
if(OK) {
LL now = cal(n/val)*pow4(val);
now = fix(now);
if(flag){
res = fix(res - now);
}else {
res = fix(res + now);
}
}
if(idx >= cnt) return;
//solve(val*factor[idx],idx);
solve(val*factor[idx],idx+1,flag^1,true);
solve(val,idx+1,flag,false);
}
void run(){
res = cal(n);
cnt = 0;
init();
solve(1,0,0,false);
//if(cnt)
//res = fix(res+1);
printf("%lld\n",res);
}
int main(){
int T;
cin>>T;
while(T --){
scanf("%lld",&n);
run();
}
}
/*
123
10
12
100
1000
10000
1
2
3
4
5
100000000
*/
3547 The Boss on Mars
最新推荐文章于 2021-09-03 23:39:59 发布