Cod sursa(job #120517)
Utilizator | Data | 5 ianuarie 2008 19:31:44 | |
---|---|---|---|
Problema | Sum | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream.h>
using namespace std;
long long u[100001],tot[100001];
void totient()
{
long i,j;
for (i=2;i<=100001;i++)
tot[i]=i;
for (i=2;i<=100001;i++)
{
if (u[i]==0)
{
j=1;
while(i*j<=100001)
{
u[i*j]=1;
tot[i*j]=tot[i*j]-(tot[i*j]/i);
j++;
} }
}
}
int main()
{ long long n;
totient();
ifstream f1("sum.in");
ofstream f2("sum.out");
f1>>n;
sol=2*n*tot[n];
f2<<sol;
return 0;
}