Cod sursa(job #529980)
| Utilizator | Data | 6 februarie 2011 17:09:23 | |
|---|---|---|---|
| Problema | Sum | Scor | 85 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
#define XMAX 100002
using namespace std;
long long sum[2 * XMAX];
int main()
{
int n, x;
ifstream f("sum.in");
ofstream g("sum.out");
f >> n;
for(int i = 1; i <= XMAX; ++i)
sum[i] = i - 1;
for(int i = 2; i <= XMAX; ++i)
for(int j = 2 * i; j <= XMAX; j += i)
sum[j] -= sum[i];
for(int i = 1; i <= n; ++i)
{
f >> x;
long long S = (sum[x] * (long long) x) * 2;
g << S << '\n';
}
f.close();
g.close();
return 0;
}
