Pagini recente » Cod sursa (job #2636766) | Cod sursa (job #2721733) | Cod sursa (job #876735) | Cod sursa (job #274627) | Cod sursa (job #2297434)
#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;
}