Cod sursa(job #2443348)
Utilizator | No Name Storak | Data | 27 iulie 2019 14:37:07 |
---|---|---|---|
Problema | Sum | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.44 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in("sum.in");
ofstream out("sum.out");
const int N = 1e5;
long long phi[N+5];
int main()
{
for (int i = 1; i<=N; i++)
phi[i] = i-1;
for (int i = 1; i<=N; i++)
for (int j = 2*i; j<=N; j+=i)
phi[j]-=phi[i];
int t;
in >> t;
while (t--)
{
long long n;
in >> n;
out << 2*n*phi[n] << "\n";
}
}