You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.0 KiB

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
//快读
int read() {
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 << 3) + (x << 1) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
const int N = 1010;
// 功能:欧拉函数
int get_euler(int x) {
int res = x;
for (int i = 2; i <= x / i; i++)
if (x % i == 0) {
res = res / i * (i - 1);
while (x % i == 0) x /= i;
}
if (x > 1) res = res / x * (x - 1);
return res;
}
int main() {
int n, m = read();
for (int i = 1; i <= m; i++) {
n = read();
int res = 1; // x=y 记1个
for (int j = 1; j <= n; j++) res += get_euler(j) * 2; //叠加两倍的欧拉函数值
printf("%d %d %d\n", i, n, res);
}
return 0;
}