fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. int N;
  9. cin >> N;
  10.  
  11. long long ans = 0;
  12.  
  13. // x <= y
  14. for (int x = 1; x * 2 <= N; x++) {
  15. for (int y = x; y <= N; y++) {
  16.  
  17. if ((long long)y * (x + y) > N) break;
  18. if (__gcd(x, y) != 1) continue;
  19.  
  20. long long kmax = (long long)N / (y * (x + y));
  21. ans += kmax;
  22. }
  23. }
  24.  
  25. cout << ans << "\n";
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5288KB
stdin
5
stdout
2