Advertisement
YanikusGG

Number of divisors

Jun 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <string>
  7. #include <vector>
  8. #include <map>
  9. #include <set>
  10.  
  11. //#include "BigInt.h"
  12.  
  13. using namespace std;
  14.  
  15. #define ll long long
  16. #define ull unsigned long long
  17. const ll INF = 999999999999999999;
  18. const double PI = acos(-1.0);
  19.  
  20. void stop()
  21. {
  22. #ifndef ONLINE_JUDGE
  23.     system("pause");
  24. #endif
  25.     exit(0);
  26. }
  27.  
  28.  
  29.  
  30. int main()
  31. {
  32.     //freopen(".in", "r", stdin);
  33.     //freopen(".out", "w", stdout);
  34.     ios::sync_with_stdio(false);
  35.  
  36.     ll n;
  37.     cin >> n;
  38.     ll res = 0;
  39.     for (ll i = 1; i*i <= n; i++)
  40.     {
  41.         res += n / i;
  42.     }
  43.     res *= 2;
  44.     res -= (ll)sqrt(n)*(ll)sqrt(n);
  45.     cout << res;
  46.  
  47.     stop();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement