Cod sursa(job #529993)
| Utilizator | Data | 6 februarie 2011 17:21:10 | |
|---|---|---|---|
| Problema | Sum | Scor | 85 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
#define XMAX 100002
using namespace std;
long long sum[XMAX + 2];
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 / 2; ++i)
for(int j = i + i; j <= XMAX; j += i)
sum[j] -= sum[i];
for(int i = 1; i <= n; ++i)
{
f >> x;
g << 2 * (sum[x] * (long long) x) << '\n';
}
f.close();
g.close();
return 0;
}
