Cod sursa(job #1119574)

Utilizator SebiCarhatCarhat Eusebiu SebiCarhat Data 24 februarie 2014 18:38:24
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.35 kb
#include<fstream>
using namespace std;

ifstream f("fractii.in");
ofstream g("fractii.out");

int n, a[1000002], i, j;
long long sol;

int main()
{
    f>>n;
    for(i=2;i<=n;i++)
                     a[i]=i-1;
    for(i=2;i<=n;i++)
{       sol=sol+a[i];
        for(j=i+i;j<=n;j+=i)
            a[j]=a[j]-a[i];}
g<<2*sol+1<<"\n";


}