Advertisement
kdzhr

Untitled

Jan 9th, 2020
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. // OK B region first tour 17/18
  2.  
  3. # include <iostream>
  4. # include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int64_t check(double x) {
  9.     double const EPS = 0.0000001;
  10.     if (abs(ceil(x) - x) <= EPS) {
  11.         return ceil(x);
  12.     } else {
  13.         return floor(x);
  14.     }
  15. }
  16.  
  17. int main() {
  18.     int64_t a, b, k;
  19.     cin >> a;
  20.     cin >> b;
  21.     cin >> k;
  22.     int64_t res = 0;
  23.     auto example = static_cast<int64_t> (check(pow(b, 1 / 3.0)));
  24.     for (size_t i = static_cast<int64_t> (ceil(pow(a, 1 / 3.0))); i <= static_cast<int64_t> (check(pow(b, 1 / 3.0))); i++) {
  25.         int64_t left = max(static_cast<int64_t> (ceil(pow(max(pow(i, 3) - k, 1.0), 1 / 2.0))), static_cast<int64_t> (ceil(pow(a, 1 / 2.0))));
  26.         int64_t right = min(static_cast<int64_t> (check(pow(pow(i, 3) + k, 1 / 2.0))), static_cast<int64_t> (check(pow(b, 1 / 2.0))));
  27.         res += max(right - left + 1, static_cast<int64_t> (0));
  28.     }
  29.     cout << res;
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement