Cod sursa(job #1051272)
| Utilizator | Data | 9 decembrie 2013 21:33:29 | |
|---|---|---|---|
| Problema | Sum | Scor | 90 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include <fstream>
using namespace std;
const int MAX_X = 100002;
int N;
int phi[MAX_X];
int main() {
ifstream f("sum.in");
ofstream g("sum.out");
for(int i = 2; i < MAX_X; ++i)
phi[i] = i - 1;
for(int i = 2; i < MAX_X; ++i)
for(int j = 2 * i; j < MAX_X; j += i)
phi[j] -= phi[i] ;
f >> N;
for(int i = 1, x; i <= N; ++i) {
f >> x;
g << (long long) 2 * phi[x] * x << "\n";
}
f.close();
g.close();
return 0;
}
