求区间欧拉函数平方和。。。
最后因为longlong 范围爆了WA 了, 0.0
#include<bits/stdc++.h>
using namespace std;
const int maxn = 5000000 + 131;
typedef unsigned long long LL;
bool Com[maxn];
LL Num[maxn], Prim[maxn / 3];
int Cnt;
void INIT()
{
Num[1] = 1, Num[0] = 0;
for(LL i = 2; i <= maxn; ++i)
{
if(!Com[i])
{
Prim[Cnt++] = i;
Num[i] = i-1;
}
for(LL j = 0; j < Cnt && i * Prim[j] < maxn; ++j)
{
Com[i*Prim[j]] = true;
if(i % Prim[j] == 0)
{
Num[i*Prim[j]] = Num[i] * Prim[j];
break;
}
else
Num[i*Prim[j]] = Num[i] * (Prim[j]-1);
}
}
for(LL i = 0; i < maxn; ++i) Num[i] *= Num[i];
for(LL i = 1; i < maxn; ++i) Num[i] += Num[i-1];
}
int main()
{
INIT();
//cout << Num[maxn - 1] << endl;
int t, a, b;
scanf("%d",&t);
for(int kase = 1; kase <= t; ++ kase)
{
scanf("%d%d",&a,&b);
a = a - 1;
printf("Case %d: %llu\n",kase, Num[b]-Num[a]);
}
}