Cod sursa(job #2780925)
| Utilizator | Data | 8 octombrie 2021 09:56:39 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <fstream>
using namespace std;
const int nmax = 100000;
int phi[nmax + 1];
inline void calc_phi(){
for ( int i = 2; i <= nmax; i++ )
phi[i] = i;
for ( int i = 2; i <= nmax; i++ )
if ( phi[i] == i )
for ( int j = i; j <= nmax; j += i )
phi[j] = phi[j] / i * (i - 1);
}
ifstream fin ( "sum.in" );
ofstream fout ( "sum.out" );
int main(){
int t, n;
calc_phi ();
for ( fin >> t; t; t-- ){
fin >> n;
fout << (long long) 2 * phi[n] * n << '\n';
}
return 0;
}
