# [SMOJ2004]^=^笑脸

a=(d1)k1÷b×(d2)k2÷b××(dm)km÷b

c=(d1)k1÷d×(d2)k2÷d××(dm)km÷d

b=g×lcm(y,z)y

d$d$ 也是类似的。题目要求满足 b$b$d$d$ 都小于 n$n$，即

g×lcm(y,z)yng×lcm(y,z)zn

gnylcm(y,z)gnzlcm(y,z)

gminnylcm(y,z)nzlcm(y,z)

gn×min{y,z}lcm(y,z)

g=n×min{y,z}lcm(y,z)

//2004.cpp
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

#define aspe MOD

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;

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

bool flag[MAXN];

int main(void) {
freopen("2004.in", "r", stdin);
freopen("2004.out", "w", stdout);
for (long long i = 2; i * i <= MAXN; i++)
for (long long j = i * i; j <= MAXN; j *= i)
flag[j] = true;
long long T; cin >> T; //printf("%lld\n", T);
while (T--) {
long long N; cin >> N; //cout << N << endl; //printf("%lld\n", N);
long long ans = (long long)N * N % aspe;
for (long long k = 2; k <= N; k++) {
if (flag[k]) continue; //cout << k << endl;
for (long long x = 1, kx = k; kx <= N; x++, kx *= k)
for (long long y = 1, ky = k; ky <= N; y++, ky *= k) {
(ans += min(x, y) * N / (x * y % aspe / gcd(x, y))) %= aspe;
//                  printf("k = %d, x = %d, y = %d, ans = %d\n", k, x, y, ans);
}
}
cout << ans << endl;
}
return 0;
}

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120