Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <fstream>
- #include <cmath>
- #include <math.h>
- #include <queue>
- #include <string>
- using namespace std;
- ifstream fin("fractii.in");
- ofstream fout("fractii.out");
- double phi(int n)
- {
- double rez = n;
- for (int i = 2; i*i <= n; i++)
- {
- if (n%i == 0) {
- while (n%i == 0) n /= i;
- rez = rez * (1.0 - (1.0 / (double)i));
- }
- }
- if (n > 1)
- rez = rez * (1.0 - (1.0 / (double)n));
- return rez;
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- int n;
- long long total = 0;
- fin >> n;
- total = 0;
- for (int i = 1; i <= n; i++)
- total += round(phi(i));
- fout << total*2 - 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement