# [bzoj4815]: [Cqoi2017]小Q的表格

$$Ans=\sum_{g=1}^{n}num(g)*\sum_{i=1}^{\lfloor\frac{n}{g}\rfloor}\sum_{j=1}^{\lfloor\frac{n}{g}\rfloor}ijg^{2}*[gcd(i,j)==1]$$

$$G(n)=\sum_{i=1}^{n}\sum_{j=1}^{n}i*j*[gcd(i,j)==1]$$

$$Ans=\sum_{g=1}^{n}num(g)*G(\lfloor\frac{n}{g}\rfloor)$$
$\lfloor\frac{n}{g}\rfloor$只有根号种取值，所以只需要维护前面那东西的前缀和就行了

#include<iostream>
#include<cstdio>
#include<cmath>
#define ll long long
#define MN 4000000
#define MB 2000
#define mod 1000000007
using namespace std;
{
int x = 0; char ch = getchar();
while(ch < '0' || ch > '9')ch = getchar();
while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
return x;
}
{
ll x = 0 ; char ch = getchar();
while(ch < '0' || ch > '9')  ch = getchar();
while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
return x;
}
int num[MN+5];
bool b[MN+5];

inline int gcd(int x,int y) {return !y?x:gcd(y,x%y);}

{
int bl=(x-1)/block+1,M=min(n,bl*block);
}

int Query(int x)
{
if(!x) return 0;
int bl=(x-1)/block+1;
}

int main()
{
for(int i=2;i<=n;++i)
{
if(!b[i]) phi[s[++cnt]=i]=i-1;
for(int j=1;s[j]*i<=n;++j)
{
b[s[j]*i]=1;
if(i%s[j]==0){ phi[s[j]*i]=phi[i]*s[j];break;}
phi[s[j]*i]=phi[i]*(s[j]-1);
}
phi[i]=(phi[i-1]+1LL*i*i%mod*phi[i])%mod;
num[i]=(num[i-1]+1LL*i*i)%mod;
}
for(int i=1;i<=m;++i)
{
}