Cod sursa(job #529985)
Utilizator | Catalin Haidau Catah15 | Data | 6 februarie 2011 17:11:32 |
---|---|---|---|
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[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 = 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;
}