Cod sursa(job #1231982)

Utilizator vtt271Vasile Toncu vtt271 Data 21 septembrie 2014 20:22:58
Problema Fractii Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
#include <fstream>

using namespace std;

ifstream inFile("fractii.in");
ofstream outFile("fractii.out");

int phi[1000005];

int main()
{
    int n;
    inFile >> n;

    int ct = 0;

    for(int i = 1; i <= n; i++){
        phi[i] = i-1;
    }

    for(int i = 2; i <= n/2; i++){
        for(int j = i+i; j <= n; j+=i) phi[j]-=phi[i];
    }

    for(int i = 2; i <= n; i++) ct+=2*phi[i];

    outFile << ct+1;
}