Cod sursa(job #2297434)
Utilizator | Data | 5 decembrie 2018 20:32:48 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.46 kb |
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int main() {
int N;
fin >> N;
vector <int> TotF(1 + N);
for (int no = 2; no <= N; ++no)
TotF[no] = no - 1;
for (int no = 2; no <= N; ++no)
for (int mult = 2 * no; mult <= N; mult += no)
TotF[mult] -= TotF[no];
long long sum = 0;
for (int no = 2; no <= N; ++no)
sum += TotF[no];
fout << 2 * sum + 1;
}