Pagini recente » Cod sursa (job #1338924) | Cod sursa (job #1831007) | Cod sursa (job #3291928) | Fmi No Stress 9 | Cod sursa (job #2197106)
#include <cstdio>
#define VM 100000
using namespace std;
int e[VM + 1];
inline void calc_Euler() {
for ( int i = 2; i <= VM; i ++ )
e[i] = i;
for ( int i = 2; i <= VM; i ++ )
if ( e[i] == i )
for ( int j = i; j <= VM; j += i )
e[j] = e[j] / i * ( i - 1 );
}
int main() {
int n, nr;
FILE *fin, *fout;
fscanf( fin, "%d", &n );
calc_Euler();
for ( int i = 0; i < n; i ++ ) {
fscanf( fin, "%d", &nr );
fprintf( fout, "%lld\n", (long long)e[nr] * nr * 2 );
/// cmmdc( x, n ) = 1 => cmmdc( 2n - x, n ) = 1;
}
return 0;
}