Cod sursa(job #981483)
| Utilizator | Data | 7 august 2013 12:05:16 | |
|---|---|---|---|
| Problema | Sum | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.49 kb |
#include <stdio.h>
#include <math.h>
#define dim 100005
using namespace std;
int main()
{
int n, phi[ dim ], x;
for( int i = 2; i < dim; i++ )
phi[ i ] = i-1;
for( int i = 2; i < dim; i++ )
for( int j = 2*i; j < dim; j += i )
phi[ j ] -= phi[ i ];
FILE *f = fopen("sum.in","r"), *g = fopen("sum.out","w");
fscanf( f,"%d", &n );
while(n--)
{
fscanf( f,"%d", &x );
fprintf( g,"%lld\n", 1LL*2*phi[x]*x );
}
fclose( f );
fclose( g );
return 0;
}
