Cod sursa(job #2405200)
Utilizator | Dron Ionut-Gabriel gabi08 | Data | 14 aprilie 2019 09:33:15 |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
#define nmax 1000005
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
int n, sol;
int v[nmax];
int main()
{
in >> n;
for (int i = 1; i <= n; v[i++] = i);
for (int i = 2; i <= n; ++i)
{
--v[i];
for (int j = 2 * i; j <= n; j += i)
v[j] -= v[i];
}
for (int i = 1; i <= n; sol += 2 * v[i++]);
out << sol - 1;
system("pause");
}