Cod sursa(job #2779980)
Utilizator | Data | 5 octombrie 2021 17:35:56 | |
---|---|---|---|
Problema | Sum | Scor | 70 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.58 kb |
#include <iostream>
#include <fstream>
using namespace std;
int e[100001];
void euler(int n){
for(int i = 2; i <= n; i++)
e[i]=i;
for(int i = 2; i <= n; i++){
if(e[i] == i){
for(int j = i; j <= n; j += i)
e[j] = e[j] / i * (i - 1);
}
}
}
int main()
{
ifstream fin("sum.in");
ofstream fout("sum.out");
int n;
fin >> n;
euler(100000);
for(int cnt = 0; cnt < n; cnt++){
int x;
fin >> x;
fout << e[x] * 2 * x << "\n";
}
return 0;
}