Cod sursa(job #2592480)
Utilizator | Daniel Popescu darkeagle | Data | 1 aprilie 2020 18:47:48 |
---|---|---|---|
Problema | Sum | Scor | 95 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
#define nmax 100005
using namespace std;
ifstream fin("sum.in");
ofstream fout("sum.out");
int n;
long long phi[nmax];
int main() {
int i, j, x;
long long t;
for(i=1;i<nmax;i++)
phi[i]=i;
for(i=1;i<nmax;i++) {
for(j = 2*i;j <= nmax;j+=i) {
phi[j] -= phi[i];
}
}
fin >> n;
for (i = 1; i <= n;i++) {
fin >> x;
t = (long long)x * phi[x] *2;
fout << t << "\n";
}
return 0;
}