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