Cod sursa(job #1601025)
Utilizator | Data | 15 februarie 2016 17:47:03 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int n;
fin >> n;
int a[1000001];
for (int i = 2; i <= n; i++)
a[i] = i - 1;
for (int i = 2; i <= n; i++)
for (int j = i * 2; j <= n; j += i)
a[j] -= a[i];
long long s = 1;
for (int i = 2; i <= n; i++)
s += a[i] * 2;
fout << s << endl;
}