hdu 4059

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <fstream>

using namespace std;

#define PF(x) (scanf("%d",&x))
#define PT(x,y) (scanf("%d%d",&x,&y))
#define PR(x) (printf("%d\n",x))
#define PRT(x,y)(printf("%d %d\n",x,y))
#define PB(x)(scanf("%I64d",&x))
#define PRB(x)(printf("%I64d\n",(x)))
typedef __int64 LL;
#define N 100005
#define M 105
#define Mod  1000000007
#define Inf 0x7fffffff

LL prime[N];
int is[N];
LL factor[N];
int tos;
LL ress;


LL modpow(LL a,LL n)
{
	if(n == 1) return a;
	if(n==0) return 1;
	LL res = 1;
	while(n)
	{
		if(n&1) res *= a,res %= Mod;
		a *= a;
		a %= Mod;
		n >>= 1;
	}
	return res;
}

LL pow4(LL n)
{
	LL res = 1;
	res = res*n%Mod;
	res = res*n%Mod;
	res = res*n%Mod;
	res = res*n%Mod;
	return res;
}
void fact(LL n)
{
	tos = 0;
	LL nn = n;
	for(int i=0;prime[i] *prime[i]<=n;i++)
	{
		if(n%prime[i] == 0)
		{
			factor[tos++] = prime[i];
			while(nn%prime[i] == 0) nn /= prime[i];
		}
	}
	if(nn>1) factor[tos++] = nn;
	return ;
}

void creatprime()
{
	ress =  modpow(30,Mod-2);
	memset(is,0,sizeof(is));
	int p = 0;
	prime[p++]= 2;
	for(LL i=2;i<N;i+=2) is[i] = 1;
	for(LL i=3;i<N;i+=2)
	{
		if(!is[i])
		{
			prime[p++] = i;
			for(LL j = i+i;j<N;j+=i)
				is[j] = 1;
		}
	}
}
LL sum(LL n)
{
	LL res = n;
	res = res *(n+1)%Mod;
	res = res *(2*n+1)%Mod;
	res = res *(n*n%Mod*3%Mod + 3*n%Mod - 1+Mod)%Mod;
	return res *ress%Mod;
}
LL dfs(int cur,LL n)
{
	LL res = 0;
	LL tmp;
	for(int i= cur;i<tos;i++)
	{
		tmp = factor[i];
		res = (res + sum(n/tmp)*pow4(tmp)%Mod)%Mod;
		res = ((res - dfs(i+1,n/tmp)*pow4(tmp)%Mod)%Mod+Mod)%Mod;
	}
	return res%Mod;
}
void init()
{
	creatprime();
	int test;
	PF(test);
	while(test--)
	{
		LL n;
		PB(n);
		if(n == 1) {puts("0");continue;}
		fact(n);
		PRB( (sum(n) - dfs(0,n) + Mod)%Mod);
	}
	return ;
}

int main()
{
	init();
	return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值