0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:08:47 +00:00

3090. Visible Lattice Points

23173858
This commit is contained in:
Baoshuo Ren 2022-01-14 16:37:03 +08:00
parent de1ff21462
commit 12c7f26fe4
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

35
POJ/3090/3090.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
const int N = 1005;
int _t, n, phi[N], ans;
int main() {
// Init
for (int i = 2; i <= 1000; i++) {
phi[i] = i;
}
for (int i = 2; i <= 1000; i++) {
if (phi[i] == i) {
for (int j = i; j <= 1000; j += i) {
phi[j] = phi[j] / i * (i - 1);
}
}
}
// End: Init
cin >> _t;
for (int t = 1; t <= _t; t++) {
ans = 0;
cin >> n;
for (int i = 2; i <= n; i++) {
ans += phi[i];
}
cout << t << ' ' << n << ' ' << ans * 2 + 3 << endl;
}
return 0;
}