Cod sursa(job #1349786)

Utilizator StefanutzzKis Stefan Marian Stefanutzz Data 20 februarie 2015 14:47:22
Problema Fractii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <iostream>
#include <fstream>
   
using namespace std;
   
ifstream in("fractii.in");
ofstream out("fractii.out");
   
int v[1000005];
   
int main()
{
    long long k = 0;
    int n, i, j;
    in >> n;
    for(i = 2; i <= n; i++) {
        v[i] = i - 1;
    }
    for(i = 2; i <= n; i++) {
        for(j = i + i; j <= n; j = j + i) {
            v[j] = v[j] - v[i];
            }
        k += v[i];
    }
    out << 2 * k + 1;
    in.close();
    out.close();
    return 0;
}