Cod sursa(job #1207594)
| Utilizator | Data | 13 iulie 2014 14:25:44 | |
|---|---|---|---|
| Problema | Sum | Scor | 85 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <fstream>
#include <algorithm>
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
const int MAX_N = 100000;
long long c[MAX_N+10];
int main() {
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;
fin >> n;
for(int i = 1; i <= n; i++) {
long long x;
fin >> x;
fout << (long long)c[x] * 2 * x << '\n';
}
return 0;
}
