Cod sursa(job #1478902)
Utilizator | Data | 29 august 2015 21:34:45 | |
---|---|---|---|
Problema | Sum | Scor | 95 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.63 kb |
#include <bits/stdc++.h>
#define nmax 100010
using namespace std;
int a[nmax];
long long cnt;
int main()
{
int n, i, j, x;
ifstream fin("sum.in");
ofstream fout("sum.out");
fin >> n;
/// indicatorul lui Euler
for (j = 1; j <= nmax; j++)
a[j]=j;
for (i = 2; i <= nmax; i++)
if (a[i] == i)
for (j = i; j <= nmax; j += i)
a[j] = a[j] / i * (i - 1);
/// query
for (i = 1; i <= n; i++)
{
fin >> x;
cnt = 1LL * x * a[x] * 2;
fout << cnt << "\n";
}
fin.close();
fout.close();
return 0;
}