Cod sursa(job #808128)
Utilizator | Data | 6 noiembrie 2012 09:56:20 | |
---|---|---|---|
Problema | Fractii | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include <cstdio>
using namespace std;
int n,s[1000001];
unsigned long long suma;
int main()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
scanf("%d",&n);
int i;
for(i=2;i<=n;++i) s[i]=i-1;
for(i=2;i<=n;++i)
{ suma+=s[i];
for(int j=i+i; j<=n; j += i) s[j]-=s[i];
}
printf("%d\n",suma*2+1);
return 0;
}