Advertisement
Dang_Quan_10_Tin

CALCULATE

May 16th, 2022
647
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define task "CALCULATE"
  2. #include <iostream>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7. using ll = long long;
  8. using ld = long double;
  9.  
  10. constexpr int N = 1e5 + 5;
  11. ll n;
  12.  
  13. #define Cal(a, b) ((b) - (a) + 1)
  14.  
  15. void Solve()
  16. {
  17.     ll ans = 0;
  18.  
  19.     for (ll i = 1; i <= n / i; ++i)
  20.         ans += Cal(n / (i + 1) + 1, n / i) * i;
  21.  
  22.     for (ll i = 1; i < n / i; ++i)
  23.         ans += n / i;
  24.    
  25.     cout << ans << '\n';
  26. }
  27.  
  28. int32_t main()
  29. {
  30.     ios_base::sync_with_stdio(0);
  31.     cin.tie(0);
  32.     cout.tie(0);
  33.  
  34.     if (fopen(task ".INP", "r"))
  35.     {
  36.         freopen(task ".INP", "r", stdin);
  37.         freopen(task ".OUT", "w", stdout);
  38.     }
  39.     while (cin >> n)
  40.     {
  41.         Solve();
  42.     }
  43. }
Advertisement
RAW Paste Data Copied
Advertisement