Cod sursa(job #1148967)
| Utilizator | Data | 21 martie 2014 12:57:35 | |
|---|---|---|---|
| Problema | Sum | Scor | 95 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <fstream>
using namespace std;
const int Xmax = int(1e5) + 5;
int ans[Xmax];
int main()
{
ifstream cin("sum.in");
ofstream cout("sum.out");
for (int i = 2; i < Xmax; i++) {
ans[i] += (i - 1);
for (int j = i + i; j < Xmax; j += i) {
ans[j] -= ans[i];
}
}
int testCount;
int x;
cin >> testCount;
while (testCount--) {
cin >> x;
cout << 2LL * ans[x] * x << "\n";
}
return 0;
}
