## 4407: 于神之怒加强版

Time Limit: 80 Sec   Memory Limit: 512 MB

Submit: 624

Solved: 297

[Submit][Status][Discuss]

1 2
3 3

20

## HINT

1<=N,M,K<=5000000,1<=T<=2000

## Source

【代码】

//bzoj 4407 于神之怒加强版
#include<cstdio>
#include<cstring>
#include<iostream>
#define N 5000000
#define P 1000000007
#define ll long long
#define M(a) memset(a,0,sizeof a)
#define fo(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
const int mxn=5000005;
int n,m,K,T;
bool vis[mxn];
int pri[mxn];
ll g[mxn],pw[mxn];
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x*f;
}
inline ll calc(ll x,int k)
{
ll ans=1;
while(k)
{
if(k&1) ans=ans*x%P;
x=x*x%P;
k>>=1;
}
return ans%P;
}
inline void init()
{
g[1]=pw[1]=1;
fo(i,2,N)
{
if(!vis[i])
pri[++pri[0]]=i,pw[i]=calc((ll)i,K),g[i]=pw[i]-1;
for(int j=1;j<=pri[0]&&i*pri[j]<=N;j++)
{
vis[i*pri[j]]=1;
if(i%pri[j]==0)
{
g[i*pri[j]]=g[i]*pw[pri[j]]%P;
break;
}
g[i*pri[j]]=g[i]*g[pri[j]]%P;
}
}
fo(i,2,N) g[i]=(g[i]+g[i-1])%P;
}
inline ll solve(int n,int m)
{
ll ans=0;
for(int i=1,last=0;i<=n;i=last+1)
{
last=min(n/(n/i),m/(m/i));
ans=(ans+(ll)(n/i)*(ll)(m/i)%P*(g[last]-g[i-1]+P)%P)%P;
}
return (ans+P)%P;
}
int main()
{
}