#include"bits/stdc++.h"
using namespace std;
typedef long long LL;
const int MX = 1e7+7;
const int mod = 1<<30;
bool no_prime[MX];
int prime[MX],f[2][MX],h[MX],tail;
void init()
{
int n = 1e7;
f[0][1] = f[1][1] = 1, h[1] = 1;
for(int i = 2; i<= n; i++){
if(!no_prime[i]){
prime[++tail] = i;
f[0][i] = f[1][i] = i;
h[i] = i-2;
}
for(int j = 1; j <= tail; j++){
int x = i*prime[j];
if(x > n) break;
no_prime[x] = 1;
int p = prime[j];
if(i % p == 0){
int temp = i;
int cnt = 1;
while(cnt < 3 && temp % p == 0) temp /= p, ++cnt;
f[0][x] = f[0][i/p]*p;
if(cnt == 2) f[1][x] = f[1][i/p]*p;
else f[1][x] = f[1][i/p/p]*p;
if(cnt == 2) h[x] = h[i/p]*(p-1)*(p-1);
else h[x] = h[i]*p;
break;
}
f[0][x] = f[0][i]*p;
f[1][x] = f[1][i]*p;
h[x] = h[i]*(p - 2);
}
}
}
void upd(LL &a, LL b)
{
a = (a+b)%mod;
}
void solve()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
LL ans = 0;
for(int i = 1; i <= a; i++){
upd(ans,1LL*h[i]*(a/i)%mod *(b/f[0][i])%mod *(c/f[1][i])%mod);
}
printf("%lld\n",ans);
}
int main()
{
int T;
init();
cin>>T;
while(T--) solve();
return 0;
}
hdu 6428 Calculate
猜你喜欢
转载自blog.csdn.net/qq_18869763/article/details/81989312
今日推荐
周排行