Cod sursa(job #1472697)
| Utilizator | Data | 17 august 2015 16:34:10 | |
|---|---|---|---|
| Problema | Sum | Scor | 85 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int Max = 100000;
int phi[Max];
void Solve(){
for (int i = 1; i <= 100000; ++i)
phi[i] = i-1;
for (int i = 2; i <= 100000; ++i)
for (int j = 2*i; j <= 100000; j += i)
phi[j] -= phi[i];
}
int main(){
ifstream fin("sum.in");
ofstream fout("sum.out");
int n;
long long X;
Solve();
fin >> n;
while (n){
fin >> X;
fout << 2 * X * phi[X] << "\n";
n--;
}
fin.close();
fout.close();
return 0;
}
