fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define fast ios::sync_with_stdio(false); cin.tie(nullptr);
  5. #define ll long long
  6. #define endl '\n'
  7. #define all(v) (v).begin(), (v).end()
  8. #define rall(v) (v).rbegin(), (v).rend()
  9.  
  10. const int oo = 1e9;
  11. const ll INF = 1e18;
  12. const ll MOD = 1e9+7;
  13.  
  14. void solve(){
  15. ll n; cin >> n;
  16. ll ans = 0;
  17. ll l=1 , r=1;
  18. while(l<n){
  19. ll q = n/l;
  20. r = min(n/q , n);
  21. ll sum = (r-l+1)*(r+l)/2;
  22. ans = ( ans % MOD + (sum % MOD * q % MOD) % MOD ) %MOD;
  23. l = r + 1;
  24. }
  25. cout<<ans;
  26. }
  27.  
  28. int main()
  29. {
  30. fast
  31.  
  32. int t = 1;
  33. // cin >> t;
  34.  
  35. while (t--)
  36. solve();
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0.56s 5328KB
stdin
Standard input is empty
stdout
-652367001