anon20016

P

Oct 20th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. #include <map>
  4. #include <vector>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. #define li long long
  10.  
  11. li phi(li n) {
  12. li result = n;
  13. for (li i = 2; i * i <= n; ++i)
  14. if (n % i == 0) {
  15. while (n % i == 0)
  16. n /= i;
  17. result -= result / i;
  18. }
  19. if (n > 1)
  20. result -= result / n;
  21. return result;
  22. }
  23. int main() {
  24. li a, b;
  25. cin >> a >> b;
  26. li ans = 0;
  27. for (li i = a; i <= b; i++) {
  28. ans += phi(i);
  29. }
  30. cout << ans;
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment