Cod sursa(job #2165299)

Utilizator blacktundraTudorescu Ana-Maria blacktundra Data 13 martie 2018 11:46:37
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include <bits/stdc++.h>
#define nmax 1000001

using namespace std;

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

int a[nmax],n;

void Read()
{
     f>> n;

    for (int i =2; i<=n; ++i)
        a[i]=i-1;

    for (int i=2; i<=n; ++i)
        for (int j=2*i; j<=n; j+=i)
            a[j]-=a[i];

    long long sum=0;

    for(int i=2; i<=n; ++i)
        sum+=a[i];

    g<<2*sum+1;
}

int main()
{
    Read();
}