Cod sursa(job #2717398)
| Utilizator | Data | 7 martie 2021 12:44:12 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
long long phi[100000 + 2];
int i, j, x, t;
int main()
{
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];
fin >> t;
while(t--){
fin >> x;
fout << 2 * x * phi[x] << '\n';
}
return 0;
}
