Cod sursa(job #1211128)

Utilizator EhtRalpmetFMI Ardei Claudiu-Alexandru EhtRalpmet Data 21 iulie 2014 23:40:38
Problema Fractii Scor 90
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.41 kb
//#include<iostream>
#include<fstream>
using namespace std;

ifstream cin("fractii.in");
ofstream cout("fractii.out");

long long i,j,n,phi[1000002],s;

int main()
{
    cin>>n;
    for(i=1;i<=n;i++){
        phi[i]=i-1;
    }
    for(i=2;i<=n;i++){
        for(j=2*i;j<=n;j+=i){
            phi[j]-=phi[i];
        }
    }
    for(i=2;i<=n;i++){
        s+=phi[i];
    }
    cout<<2*s+1;
}