QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#31813#2618. Casual DancerssilxiAC ✓104ms19696kbC++2012.4kb2022-05-13 07:36:512022-05-13 07:36:53

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-13 07:36:53]
  • Judged
  • Verdict: AC
  • Time: 104ms
  • Memory: 19696kb
  • [2022-05-13 07:36:51]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// Template {{{
#define REP(n) for (int _ = 0; _ < (n); _++)
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()

template <class T>
bool ckmin(T &a, const T &b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}

namespace std {
template <class Fun>
class y_combinator_result {
  Fun fun_;

  public:
  template <class T>
  explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {}

  template <class... Args>
  decltype(auto) operator()(Args &&...args) {
    return fun_(std::ref(*this), std::forward<Args>(args)...);
  }
};

template <class Fun>
decltype(auto) y_combinator(Fun &&fun) {
  return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
}  // namespace std

#define DEBUG(x) cerr << #x << ": " << x << '\n'
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '[';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << ']';
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

// Codeforces user neal
template <const int &MOD>
struct _m_int {
  int val;

  _m_int(int64_t v = 0) {
    if (v < 0)
      v = v % MOD + MOD;
    if (v >= MOD)
      v %= MOD;
    val = int(v);
  }

  _m_int(uint64_t v) {
    if (v >= MOD)
      v %= MOD;
    val = int(v);
  }

  _m_int(int v) : _m_int(int64_t(v)) {}
  _m_int(unsigned v) : _m_int(uint64_t(v)) {}

  explicit operator int() const { return val; }
  explicit operator unsigned() const { return val; }
  explicit operator int64_t() const { return val; }
  explicit operator uint64_t() const { return val; }
  explicit operator double() const { return val; }
  explicit operator long double() const { return val; }

  _m_int &operator+=(const _m_int &other) {
    val -= MOD - other.val;
    if (val < 0)
      val += MOD;
    return *this;
  }

  _m_int &operator-=(const _m_int &other) {
    val -= other.val;
    if (val < 0)
      val += MOD;
    return *this;
  }

  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
#if !defined(_WIN32) || defined(_WIN64)
    return unsigned(x % m);
#endif
    // Optimized mod for Codeforces 32-bit machines.
    // x must be less than 2^32 * m for this to work, so that x / m fits in an
    // unsigned 32-bit int.
    unsigned x_high = unsigned(x >> 32), x_low = unsigned(x);
    unsigned quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }

  _m_int &operator*=(const _m_int &other) {
    val = fast_mod(uint64_t(val) * other.val);
    return *this;
  }

  _m_int &operator/=(const _m_int &other) { return *this *= other.inv(); }

  friend _m_int operator+(const _m_int &a, const _m_int &b) {
    return _m_int(a) += b;
  }
  friend _m_int operator-(const _m_int &a, const _m_int &b) {
    return _m_int(a) -= b;
  }
  friend _m_int operator*(const _m_int &a, const _m_int &b) {
    return _m_int(a) *= b;
  }
  friend _m_int operator/(const _m_int &a, const _m_int &b) {
    return _m_int(a) /= b;
  }

  _m_int &operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }

  _m_int &operator--() {
    val = val == 0 ? MOD - 1 : val - 1;
    return *this;
  }

  _m_int operator++(int) {
    _m_int before = *this;
    ++*this;
    return before;
  }
  _m_int operator--(int) {
    _m_int before = *this;
    --*this;
    return before;
  }

  _m_int operator-() const { return val == 0 ? 0 : MOD - val; }

  friend bool operator==(const _m_int &a, const _m_int &b) {
    return a.val == b.val;
  }
  friend bool operator!=(const _m_int &a, const _m_int &b) {
    return a.val != b.val;
  }
  friend bool operator<(const _m_int &a, const _m_int &b) {
    return a.val < b.val;
  }
  friend bool operator>(const _m_int &a, const _m_int &b) {
    return a.val > b.val;
  }
  friend bool operator<=(const _m_int &a, const _m_int &b) {
    return a.val <= b.val;
  }
  friend bool operator>=(const _m_int &a, const _m_int &b) {
    return a.val >= b.val;
  }

  static const int SAVE_INV = int(1e6) + 5;
  static _m_int save_inv[SAVE_INV];

  static void prepare_inv() {
    // Ensures that MOD is prime, which is necessary for the inverse algorithm
    // below.
    for (int64_t p = 2; p * p <= MOD; p += p % 2 + 1) assert(MOD % p != 0);

    save_inv[0] = 0;
    save_inv[1] = 1;

    for (int i = 2; i < SAVE_INV; i++)
      save_inv[i] = save_inv[MOD % i] * (MOD - MOD / i);
  }

  _m_int inv() const {
    if (save_inv[1] == 0)
      prepare_inv();

    if (val < SAVE_INV)
      return save_inv[val];

    _m_int product = 1;
    int v = val;

    do {
      product *= MOD - MOD / v;
      v = MOD % v;
    } while (v >= SAVE_INV);

    return product * save_inv[v];
  }

  _m_int pow(int64_t p) const {
    if (p < 0)
      return inv().pow(-p);

    _m_int a = *this, result = 1;

    while (p > 0) {
      if (p & 1)
        result *= a;

      p >>= 1;

      if (p > 0)
        a *= a;
    }

    return result;
  }

  friend ostream &operator<<(ostream &os, const _m_int &m) {
    return os << m.val;
  }
};

template <const int &MOD>
_m_int<MOD> _m_int<MOD>::save_inv[_m_int<MOD>::SAVE_INV];

extern const int MOD = 998244353;
using mod_int = _m_int<MOD>;

template <const int &MOD>
struct NTT {
  using ntt_int = _m_int<MOD>;

  static int highest_bit(unsigned x) {
    return x == 0 ? -1 : 31 - __builtin_clz(x);
  }

  static bool is_power_of_two(int n) { return (n & (n - 1)) == 0; }

  static int round_up_power_two(int n) {
    int bit = highest_bit(n);
    bit += bit < 0 || 1 << bit < n;
    return 1 << bit;
  }

  // Given n (a power of two), finds k such that n == 1 << k.
  static int get_length(int n) {
    assert(is_power_of_two(n));
    return __builtin_ctz(n);
  }

  vector<ntt_int> roots = {0, 1};
  vector<int> bit_reverse;
  int max_size = -1;
  ntt_int root;

  void reset() {
    roots = {0, 1};
    max_size = -1;
  }

  // Rearranges the indices to be sorted by lowest bit first, then second
  // lowest, etc., rather than highest bit first. This makes even-odd
  // div-conquer much easier.
  void bit_reorder(int n, vector<ntt_int> &values) {
    if (int(bit_reverse.size()) != n) {
      bit_reverse.assign(n, 0);
      int length = get_length(n);

      for (int i = 1; i < n; i++)
        bit_reverse[i] = (bit_reverse[i >> 1] >> 1) | ((i & 1) << (length - 1));
    }

    for (int i = 0; i < n; i++)
      if (i < bit_reverse[i])
        swap(values[i], values[bit_reverse[i]]);
  }

  void find_root() {
    max_size = 1 << __builtin_ctz(MOD - 1);
    root = 2;

    // Find a max_size-th primitive root of MOD.
    while (!(root.pow(max_size) == 1 && root.pow(max_size / 2) != 1)) root++;
  }

  void prepare_roots(int n) {
    if (max_size < 0)
      find_root();

    assert(n <= max_size);

    if (int(roots.size()) >= n)
      return;

    int length = get_length(int(roots.size()));
    roots.resize(n);

    // The roots array is set up such that for a given power of two n >= 2,
    // roots[n / 2] through roots[n - 1] are the first half of the n-th
    // primitive roots of MOD.
    while (1 << length < n) {
      // z is a 2^(length + 1)-th primitive root of MOD.
      ntt_int z = root.pow(max_size >> (length + 1));

      for (int i = 1 << (length - 1); i < 1 << length; i++) {
        roots[2 * i] = roots[i];
        roots[2 * i + 1] = roots[i] * z;
      }

      length++;
    }
  }

  void fft_iterative(int n, vector<ntt_int> &values) {
    assert(is_power_of_two(n));
    prepare_roots(n);
    bit_reorder(n, values);

    for (int len = 1; len < n; len *= 2)
      for (int start = 0; start < n; start += 2 * len)
        for (int i = 0; i < len; i++) {
          ntt_int even = values[start + i];
          ntt_int odd = values[start + len + i] * roots[len + i];
          values[start + len + i] = even - odd;
          values[start + i] = even + odd;
        }
  }

  void invert_fft(int n, vector<ntt_int> &values) {
    ntt_int inv_n = ntt_int(n).inv();

    for (int i = 0; i < n; i++) values[i] *= inv_n;

    reverse(values.begin() + 1, values.end());
    fft_iterative(n, values);
  }

  // Note: `circular = true` can be used for a 2x speedup when only the `max(n,
  // m) - min(n, m) + 1` fully overlapping ranges are needed. It computes
  // results using indices modulo the power-of-two FFT size; see the brute force
  // below.
  template <typename T>
  vector<T> mod_multiply(const vector<T> &_left, const vector<T> &_right,
                         bool circular = false) {
    if (_left.empty() || _right.empty())
      return {};

    vector<ntt_int> left(_left.begin(), _left.end());
    vector<ntt_int> right(_right.begin(), _right.end());

    int n = int(left.size());
    int m = int(right.size());

    int output_size = circular ? round_up_power_two(max(n, m)) : n + m - 1;
    int N = round_up_power_two(output_size);

    double brute_force_cost = 1.25 * n * m;
    double ntt_cost = 3.0 * N * (get_length(N) + 3);

    if (brute_force_cost < ntt_cost) {
      auto &&mod_output_size = [&](int x) {
        return x < output_size ? x : x - output_size;
      };

      static const uint64_t U64_BOUND =
          numeric_limits<uint64_t>::max() - uint64_t(MOD) * MOD;
      vector<uint64_t> result(output_size, 0);

      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
          int index = mod_output_size(i + j);
          result[index] += uint64_t(left[i]) * uint64_t(right[j]);

          if (result[index] > U64_BOUND)
            result[index] %= MOD;
        }

      for (uint64_t &x : result) x %= MOD;

      return vector<T>(result.begin(), result.end());
    }

    left.resize(N, 0);
    right.resize(N, 0);

    if (left == right) {
      fft_iterative(N, left);
      right = left;
    } else {
      fft_iterative(N, left);
      fft_iterative(N, right);
    }

    for (int i = 0; i < N; i++) left[i] *= right[i];

    invert_fft(N, left);
    return vector<T>(left.begin(), left.begin() + output_size);
  }

  template <typename T>
  vector<T> mod_power(const vector<T> &v, int exponent) {
    assert(exponent >= 0);
    vector<T> result = {1};

    if (exponent == 0)
      return result;

    for (int k = highest_bit(exponent); k >= 0; k--) {
      result = mod_multiply(result, result);

      if (exponent >> k & 1)
        result = mod_multiply(result, v);
    }

    return result;
  }

  // Multiplies many polynomials whose total degree is n in O(n log n
  // log(polynomials.size())).
  template <typename T>
  vector<T> mod_multiply_all(const vector<vector<T>> &polynomials) {
    if (polynomials.empty())
      return {1};

    struct compare_size {
      bool operator()(const vector<T> &x, const vector<T> &y) {
        return x.size() > y.size();
      }
    };

    priority_queue<vector<T>, vector<vector<T>>, compare_size> pq(
        polynomials.begin(), polynomials.end());

    while (pq.size() > 1) {
      vector<T> a = pq.top();
      pq.pop();
      vector<T> b = pq.top();
      pq.pop();
      pq.push(mod_multiply(a, b));
    }

    return pq.top();
  }
};

NTT<MOD> ntt;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  vector<int> a(3);
  F0R(i, 3) cin >> a[i];
  int k, p;
  cin >> k >> p;

  mod_int x = mod_int(3).inv();
  vector<mod_int> poly = {x, x, x};
  vector<mod_int> ans = ntt.mod_power(poly, k);
  mod_int res = 0;
  F0R(i, 2 * k + 1) {
    res += ans[i] * abs(i - k + a[0] - a[1]);
    res += ans[i] * abs(i - k + a[1] - a[2]);
    res += ans[i] * abs(i - k + a[0] - a[2]);
  }
  res /= 2;
  cout << res << endl;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 11ms
memory: 7532kb

input:

0 0 0
1
58

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 6ms
memory: 7572kb

input:

1 2 2
1
100

output:

332748119

result:

ok 1 number(s): "332748119"

Test #3:

score: 0
Accepted
time: 9ms
memory: 7556kb

input:

5 2 3
4
50

output:

160212060

result:

ok 1 number(s): "160212060"

Test #4:

score: 0
Accepted
time: 6ms
memory: 7556kb

input:

-2 -1 1
2
71

output:

443664160

result:

ok 1 number(s): "443664160"

Test #5:

score: 0
Accepted
time: 3ms
memory: 7492kb

input:

-1 0 -1
4
8

output:

751764268

result:

ok 1 number(s): "751764268"

Test #6:

score: 0
Accepted
time: 9ms
memory: 7576kb

input:

-2 -2 2
5
54

output:

801060288

result:

ok 1 number(s): "801060288"

Test #7:

score: 0
Accepted
time: 9ms
memory: 7636kb

input:

-2 2 4
8
36

output:

353135983

result:

ok 1 number(s): "353135983"

Test #8:

score: 0
Accepted
time: 9ms
memory: 7436kb

input:

8 -7 1
7
28

output:

15

result:

ok 1 number(s): "15"

Test #9:

score: 0
Accepted
time: 9ms
memory: 7632kb

input:

-7 -8 0
16
54

output:

159363041

result:

ok 1 number(s): "159363041"

Test #10:

score: 0
Accepted
time: 5ms
memory: 7492kb

input:

5 11 -11
9
32

output:

717226646

result:

ok 1 number(s): "717226646"

Test #11:

score: 0
Accepted
time: 6ms
memory: 7484kb

input:

-16 1 -9
32
8

output:

855967855

result:

ok 1 number(s): "855967855"

Test #12:

score: 0
Accepted
time: 3ms
memory: 7632kb

input:

-13 28 28
37
80

output:

116405794

result:

ok 1 number(s): "116405794"

Test #13:

score: 0
Accepted
time: 6ms
memory: 7580kb

input:

6 26 -25
64
21

output:

91053409

result:

ok 1 number(s): "91053409"

Test #14:

score: 0
Accepted
time: 4ms
memory: 7484kb

input:

-39 23 1
31
64

output:

742331784

result:

ok 1 number(s): "742331784"

Test #15:

score: 0
Accepted
time: 9ms
memory: 7476kb

input:

-32 42 43
128
87

output:

57822539

result:

ok 1 number(s): "57822539"

Test #16:

score: 0
Accepted
time: 10ms
memory: 7444kb

input:

-80 55 -106
142
29

output:

435655440

result:

ok 1 number(s): "435655440"

Test #17:

score: 0
Accepted
time: 6ms
memory: 7564kb

input:

0 -83 -106
256
55

output:

120508896

result:

ok 1 number(s): "120508896"

Test #18:

score: 0
Accepted
time: 3ms
memory: 7500kb

input:

-100 -123 -167
91
74

output:

285780715

result:

ok 1 number(s): "285780715"

Test #19:

score: 0
Accepted
time: 4ms
memory: 7540kb

input:

252 -176 -239
512
49

output:

835642397

result:

ok 1 number(s): "835642397"

Test #20:

score: 0
Accepted
time: 10ms
memory: 7628kb

input:

-37 -124 151
867
76

output:

225290884

result:

ok 1 number(s): "225290884"

Test #21:

score: 0
Accepted
time: 6ms
memory: 7584kb

input:

-316 149 -149
1024
87

output:

374987754

result:

ok 1 number(s): "374987754"

Test #22:

score: 0
Accepted
time: 4ms
memory: 7588kb

input:

370 545 81
1073
69

output:

943329809

result:

ok 1 number(s): "943329809"

Test #23:

score: 0
Accepted
time: 7ms
memory: 7616kb

input:

-81 182 532
2048
87

output:

843173062

result:

ok 1 number(s): "843173062"

Test #24:

score: 0
Accepted
time: 6ms
memory: 7508kb

input:

-1229 -1607 319
199
24

output:

1926

result:

ok 1 number(s): "1926"

Test #25:

score: 0
Accepted
time: 8ms
memory: 7624kb

input:

43 -419 -613
4096
46

output:

418220629

result:

ok 1 number(s): "418220629"

Test #26:

score: 0
Accepted
time: 5ms
memory: 7772kb

input:

3434 -3146 -1774
2601
46

output:

705802517

result:

ok 1 number(s): "705802517"

Test #27:

score: 0
Accepted
time: 11ms
memory: 7960kb

input:

2193 -2331 2901
8192
75

output:

728593792

result:

ok 1 number(s): "728593792"

Test #28:

score: 0
Accepted
time: 6ms
memory: 7652kb

input:

233 -4307 -4363
1093
81

output:

303899847

result:

ok 1 number(s): "303899847"

Test #29:

score: 0
Accepted
time: 17ms
memory: 8632kb

input:

-4522 762 8059
16384
34

output:

190696426

result:

ok 1 number(s): "190696426"

Test #30:

score: 0
Accepted
time: 17ms
memory: 8708kb

input:

-5155 -3639 15798
24822
55

output:

808461103

result:

ok 1 number(s): "808461103"

Test #31:

score: 0
Accepted
time: 20ms
memory: 9528kb

input:

15234 4368 12248
32768
19

output:

115861480

result:

ok 1 number(s): "115861480"

Test #32:

score: 0
Accepted
time: 18ms
memory: 9936kb

input:

820 30492 3951
42789
76

output:

826647308

result:

ok 1 number(s): "826647308"

Test #33:

score: 0
Accepted
time: 36ms
memory: 12868kb

input:

1372 -24835 -24597
65536
65

output:

355997764

result:

ok 1 number(s): "355997764"

Test #34:

score: 0
Accepted
time: 43ms
memory: 13068kb

input:

-59726 17559 -45875
87143
58

output:

326130350

result:

ok 1 number(s): "326130350"

Test #35:

score: 0
Accepted
time: 71ms
memory: 18028kb

input:

-27584 51950 23030
131072
74

output:

325794325

result:

ok 1 number(s): "325794325"

Test #36:

score: 0
Accepted
time: 67ms
memory: 18364kb

input:

61155 52006 74974
164861
5

output:

160748350

result:

ok 1 number(s): "160748350"

Test #37:

score: 0
Accepted
time: 67ms
memory: 18612kb

input:

41344 -81596 -95774
200000
59

output:

965482998

result:

ok 1 number(s): "965482998"

Test #38:

score: 0
Accepted
time: 17ms
memory: 8656kb

input:

42056 -90767 -54649
24350
63

output:

132823

result:

ok 1 number(s): "132823"

Test #39:

score: 0
Accepted
time: 61ms
memory: 19160kb

input:

-74335 43393 57021
199994
67

output:

310210583

result:

ok 1 number(s): "310210583"

Test #40:

score: 0
Accepted
time: 73ms
memory: 18484kb

input:

-80838 73772 -18618
134415
57

output:

346157175

result:

ok 1 number(s): "346157175"

Test #41:

score: 0
Accepted
time: 81ms
memory: 19696kb

input:

37457 74497 -81166
199997
59

output:

26667908

result:

ok 1 number(s): "26667908"

Test #42:

score: 0
Accepted
time: 104ms
memory: 18288kb

input:

31109 -65140 -77085
162412
46

output:

12858959

result:

ok 1 number(s): "12858959"

Test #43:

score: 0
Accepted
time: 60ms
memory: 18968kb

input:

-58550 -97769 66373
199995
86

output:

789346262

result:

ok 1 number(s): "789346262"

Test #44:

score: 0
Accepted
time: 28ms
memory: 13584kb

input:

7739 58831 72332
124270
16

output:

167162440

result:

ok 1 number(s): "167162440"

Test #45:

score: 0
Accepted
time: 59ms
memory: 19472kb

input:

-97901 25173 -99145
199999
52

output:

797290311

result:

ok 1 number(s): "797290311"

Test #46:

score: 0
Accepted
time: 41ms
memory: 15036kb

input:

-87118 -60882 -86669
126103
23

output:

487838027

result:

ok 1 number(s): "487838027"

Test #47:

score: 0
Accepted
time: 66ms
memory: 18616kb

input:

-71646 69885 70206
200000
27

output:

285981891

result:

ok 1 number(s): "285981891"

Test #48:

score: 0
Accepted
time: 43ms
memory: 14004kb

input:

14475 -77173 -5177
117777
51

output:

251933976

result:

ok 1 number(s): "251933976"

Test #49:

score: 0
Accepted
time: 61ms
memory: 18624kb

input:

-35780 37165 54712
199996
14

output:

763964192

result:

ok 1 number(s): "763964192"

Test #50:

score: 0
Accepted
time: 28ms
memory: 12904kb

input:

15709 -72676 -22298
101968
17

output:

406652317

result:

ok 1 number(s): "406652317"

Test #51:

score: 0
Accepted
time: 64ms
memory: 19516kb

input:

74572 -98701 -56974
199991
62

output:

55467556

result:

ok 1 number(s): "55467556"

Test #52:

score: 0
Accepted
time: 62ms
memory: 18872kb

input:

-14644 -10031 -50353
168383
43

output:

376814948

result:

ok 1 number(s): "376814948"

Test #53:

score: 0
Accepted
time: 61ms
memory: 18964kb

input:

22388 51898 80903
199995
89

output:

832434478

result:

ok 1 number(s): "832434478"

Test #54:

score: 0
Accepted
time: 37ms
memory: 14180kb

input:

34062 -76211 -25545
127193
91

output:

234760702

result:

ok 1 number(s): "234760702"

Test #55:

score: 0
Accepted
time: 68ms
memory: 18732kb

input:

-19645 -45450 -16512
200000
77

output:

759439547

result:

ok 1 number(s): "759439547"

Test #56:

score: 0
Accepted
time: 8ms
memory: 8588kb

input:

98957 80512 -24606
20311
30

output:

985804570

result:

ok 1 number(s): "985804570"

Test #57:

score: 0
Accepted
time: 65ms
memory: 18952kb

input:

-87259 -11505 14596
199994
83

output:

160520754

result:

ok 1 number(s): "160520754"

Test #58:

score: 0
Accepted
time: 62ms
memory: 18708kb

input:

0 0 0
200000
0

output:

393458944

result:

ok 1 number(s): "393458944"

Test #59:

score: 0
Accepted
time: 56ms
memory: 18624kb

input:

0 0 0
200000
100

output:

393458944

result:

ok 1 number(s): "393458944"

Test #60:

score: 0
Accepted
time: 65ms
memory: 18692kb

input:

-100000 -100000 -100000
200000
75

output:

393458944

result:

ok 1 number(s): "393458944"

Test #61:

score: 0
Accepted
time: 57ms
memory: 18688kb

input:

100000 100000 100000
200000
63

output:

393458944

result:

ok 1 number(s): "393458944"

Test #62:

score: 0
Accepted
time: 63ms
memory: 18736kb

input:

100000 0 -100000
200000
56

output:

678255914

result:

ok 1 number(s): "678255914"

Test #63:

score: 0
Accepted
time: 57ms
memory: 18720kb

input:

0 1 2
200000
22

output:

630634769

result:

ok 1 number(s): "630634769"

Test #64:

score: 0
Accepted
time: 3ms
memory: 7628kb

input:

100000 0 -100000
1
32

output:

200000

result:

ok 1 number(s): "200000"

Test #65:

score: 0
Accepted
time: 6ms
memory: 7536kb

input:

100000 100000 100000
1
33

output:

1

result:

ok 1 number(s): "1"

Test #66:

score: 0
Accepted
time: 8ms
memory: 7480kb

input:

-100000 -100000 -100000
1
6

output:

1

result:

ok 1 number(s): "1"

Test #67:

score: 0
Accepted
time: 9ms
memory: 7428kb

input:

100000 100000 -100000
1
7

output:

332948118

result:

ok 1 number(s): "332948118"

Test #68:

score: 0
Accepted
time: 10ms
memory: 7488kb

input:

-100000 -100000 100000
1
40

output:

332948118

result:

ok 1 number(s): "332948118"

Test #69:

score: 0
Accepted
time: 9ms
memory: 7644kb

input:

100000 -100000 -100000
100
63

output:

764105630

result:

ok 1 number(s): "764105630"

Test #70:

score: 0
Accepted
time: 3ms
memory: 7504kb

input:

-100000 100000 100000
100
13

output:

764105630

result:

ok 1 number(s): "764105630"

Test #71:

score: 0
Accepted
time: 6ms
memory: 7488kb

input:

-100000 100000 0
100
10

output:

200000

result:

ok 1 number(s): "200000"

Test #72:

score: 0
Accepted
time: 45ms
memory: 13344kb

input:

-100000 100000 0
99999
77

output:

200000

result:

ok 1 number(s): "200000"

Test #73:

score: 0
Accepted
time: 33ms
memory: 12924kb

input:

-100000 100000 0
100000
80

output:

200000

result:

ok 1 number(s): "200000"

Test #74:

score: 0
Accepted
time: 42ms
memory: 13192kb

input:

-100000 100000 0
100001
5

output:

50125708

result:

ok 1 number(s): "50125708"