Cod sursa(job #2268011)

Utilizator razvanboabesrazvan boabes razvanboabes Data 24 octombrie 2018 14:14:14
Problema Fractii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <fstream>

using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
int v[1000005];
void ciur( int n )
{
    for ( int i = 2; i <= n; i ++ )
        v[i] = i;
    for ( int i = 2; i <= n; i ++ )
        if ( v[i] == i )
            for ( int j = i; j <= n; j += i )
                v[j] = v[j] / i * ( i - 1 );
}
int main()
{
    long long x, s=0 , i;
    in>> x;
    ciur (x) ;
    for(i=0; i<= x; i++)
        s += v[i];
    out<< s*2+1 ;
    return 0;
}