Cod sursa(job #1208709)

Utilizator forever16Alex M forever16 Data 16 iulie 2014 14:02:06
Problema Fractii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.42 kb
#include <iostream>
#include <fstream>

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

int main()
{   int N;
    int phi[1000001];
    long long s;
    f>>N;
    for (int i = 1; i <=N; ++i)
    phi[i] = i-1;
for (int i = 2; i <= N; ++i)
    for (int j = 2*i; j <= N; j += i)
        phi[j] -= phi[i];
for (int i=2; i<=N; ++i)
        s=s+phi[i];
    g<<2*s+1;
    return 0;
}