fork download
  1. //473
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. typedef long long ll;
  5. ll L , R;
  6.  
  7. ll get(ll n){
  8. if(n == 0) return 0;
  9. ll s = sqrt(n), ans = 0;
  10. for(int i = 1; i <= n / s; i++) ans += (n / i);
  11.  
  12. // for(int i = 1; i < s; i++){
  13. // ll r = n / i;
  14. // ll l = n / (i + 1) + 1;
  15. // ans += i * (r - l + 1);
  16. // }
  17.  
  18. for(int i = 2; i <= s; i++){
  19. ll l = n / i, r = n / (i - 1);
  20. ans += (i - 1) * (r - l);
  21. }
  22.  
  23. return ans;
  24. }
  25.  
  26. int main(){
  27. ios_base::sync_with_stdio(0);
  28. cout.tie(0);
  29. cin.tie(0);
  30. freopen("tongsouoc.inp", "r", stdin); freopen("tongsouoc.out", "w", stdout);
  31. cin >> L >> R;
  32. cout << get(R) - get(L - 1);
  33.  
  34.  
  35. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty