Cod sursa(job #1207596)
| Utilizator | Data | 13 iulie 2014 14:27:49 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.64 kb |
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
long long c[MAX_N+10];
int main() {
freopen("sum.in", "r", stdin);
freopen("sum.out", "w", stdout);
for(int i = 2; i <= MAX_N; i++) {
c[i] = i;
}
for(int i = 2; i <= MAX_N; i++) {
if(c[i] == i) {
for(int j = i; j <= MAX_N; j += i) {
c[j] *= i - 1;
c[j] /= i;
}
}
}
int n;
scanf("%d", &n);
for(int i = 1; i <= n; i++) {
long long x;
scanf("%lld", &x);
printf("%lld\n", (long long)c[x] * 2 * x);
}
return 0;
}
