Cod sursa(job #992354)
Utilizator | Data | 1 septembrie 2013 18:12:01 | |
---|---|---|---|
Problema | Sum | Scor | 85 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
#define nmax 100001
using namespace std;
ifstream f("sum.in");
ofstream g("sum.out");
long long phi[nmax];
int n,x;
int main()
{
for (int i=1; i<=nmax; i++)
phi[i]=i-1;
for (int i=2; i<=nmax; i++)
for (int j=2*i; j<=nmax; j+=i)
phi[j]-=phi[i];
f >> n;
while (n--){
f >> x;
long long s=x*phi[x]*2;
g << s << "\n";
}
return 0;
}