Cod sursa(job #3280272)
| Utilizator | Data | 25 februarie 2025 22:12:57 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int n, x, k;
long long phi[100005];
int main()
{
int i, j;
fin >> n;
for (i = 1; i <= 100000; i++)
phi[i] = i - 1;
for (i = 1; i <= 100000; i++)
{
for (j = 2 * i; j <= 100000; j += i)
phi[j] -= phi[i];
}
while (n--)
{
fin >> x;
fout << phi[x] * x * 2<<'\n';
}
return 0;
}