Cod sursa(job #1907397)
| Utilizator | Data | 6 martie 2017 19:04:58 | |
|---|---|---|---|
| Problema | Sum | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <bits/stdc++.h>
using namespace std;
int n , phi[100005];
int main()
{
freopen("sum.in","r",stdin);
freopen("sum.out","w",stdout);
scanf("%d", &n);
for (int i = 1; i<=1e5; ++i)
phi[i] = i;
for (int i = 2; i<=1e5; ++i)
if (phi[i] == i)
for (int j = i; j<=1e5; j+=i)
phi[j] = (phi[j] / i )* (i-1);
for ( ; n; --n)
{
int x;
scanf("%d", &x);
printf("%d\n", 2 * x * phi[x]);
}
return 0;
}
