QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106751#5744. Palindromic DifferencesmaspyAC ✓118ms23656kbC++2319.2kb2023-05-19 02:57:462023-05-19 02:57:47

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-19 02:57:47]
  • 评测
  • 测评结果:AC
  • 用时:118ms
  • 内存:23656kb
  • [2023-05-19 02:57:46]
  • 提交

answer

#line 1 "library/my_template.hpp"
#if defined(LOCAL)
#include <my_template_compiled.hpp>
#else
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using i128 = __int128;

template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'000'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
template <>
constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;

using pi = pair<ll, ll>;
using vi = vector<ll>;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vc<T>>;
template <class T>
using vvvc = vector<vvc<T>>;
template <class T>
using vvvvc = vector<vvvc<T>>;
template <class T>
using vvvvvc = vector<vvvvc<T>>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

#define vv(type, name, h, ...) \
  vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...)   \
  vector<vector<vector<type>>> name( \
      h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)       \
  vector<vector<vector<vector<type>>>> name( \
      a, vector<vector<vector<type>>>(       \
             b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))

// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)

#define FOR_subset(t, s) \
  for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define elif else if

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second

#define stoi stoll

int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T, typename U>
T ceil(T x, U y) {
  return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U>
T floor(T x, U y) {
  return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T, typename U>
pair<T, T> divmod(T x, U y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <typename T, typename U>
T SUM(const vector<U> &A) {
  T sum = 0;
  for (auto &&a: A) sum += a;
  return sum;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) \
  sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

template <typename T>
T POP(deque<T> &que) {
  T a = que.front();
  que.pop_front();
  return a;
}
template <typename T>
T POP(pq<T> &que) {
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(pqg<T> &que) {
  assert(!que.empty());
  T a = que.top();
  que.pop();
  return a;
}
template <typename T>
T POP(vc<T> &que) {
  assert(!que.empty());
  T a = que.back();
  que.pop_back();
  return a;
}

template <typename F>
ll binary_search(F check, ll ok, ll ng, bool check_ok = true) {
  if (check_ok) assert(check(ok));
  while (abs(ok - ng) > 1) {
    auto x = (ng + ok) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return ok;
}
template <typename F>
double binary_search_real(F check, double ok, double ng, int iter = 100) {
  FOR(iter) {
    double x = (ok + ng) / 2;
    tie(ok, ng) = (check(x) ? mp(x, ng) : mp(ok, x));
  }
  return (ok + ng) / 2;
}

template <class T, class S>
inline bool chmax(T &a, const S &b) {
  return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
  return (a > b ? a = b, 1 : 0);
}

// ? は -1
vc<int> s_to_vi(const string &S, char first_char) {
  vc<int> A(S.size());
  FOR(i, S.size()) { A[i] = (S[i] != '?' ? S[i] - first_char : -1); }
  return A;
}

template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1) {
  int N = A.size();
  vector<T> B(N + 1);
  FOR(i, N) { B[i + 1] = B[i] + A[i]; }
  if (off == 0) B.erase(B.begin());
  return B;
}

// stable sort
template <typename T>
vector<int> argsort(const vector<T> &A) {
  vector<int> ids(len(A));
  iota(all(ids), 0);
  sort(all(ids),
       [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
  return ids;
}

// A[I[0]], A[I[1]], ...
template <typename T>
vc<T> rearrange(const vc<T> &A, const vc<int> &I) {
  vc<T> B(len(I));
  FOR(i, len(I)) B[i] = A[I[i]];
  return B;
}
#endif
#line 1 "library/other/io.hpp"
// based on yosupo's fastio
#include <unistd.h>

namespace fastio {
#define FASTIO
// クラスが read(), print() を持っているかを判定するメタ関数
struct has_write_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.write(), std::true_type{});

  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_write : public decltype(has_write_impl::check<T>(std::declval<T>())) {
};

struct has_read_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.read(), std::true_type{});

  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_read : public decltype(has_read_impl::check<T>(std::declval<T>())) {};

struct Scanner {
  FILE *fp;
  char line[(1 << 15) + 1];
  size_t st = 0, ed = 0;
  void reread() {
    memmove(line, line + st, ed - st);
    ed -= st;
    st = 0;
    ed += fread(line + ed, 1, (1 << 15) - ed, fp);
    line[ed] = '\0';
  }
  bool succ() {
    while (true) {
      if (st == ed) {
        reread();
        if (st == ed) return false;
      }
      while (st != ed && isspace(line[st])) st++;
      if (st != ed) break;
    }
    if (ed - st <= 50) {
      bool sep = false;
      for (size_t i = st; i < ed; i++) {
        if (isspace(line[i])) {
          sep = true;
          break;
        }
      }
      if (!sep) reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_same<T, string>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    while (true) {
      size_t sz = 0;
      while (st + sz < ed && !isspace(line[st + sz])) sz++;
      ref.append(line + st, sz);
      st += sz;
      if (!sz || st != ed) break;
      reread();
    }
    return true;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  bool read_single(T &ref) {
    if (!succ()) return false;
    bool neg = false;
    if (line[st] == '-') {
      neg = true;
      st++;
    }
    ref = T(0);
    while (isdigit(line[st])) { ref = 10 * ref + (line[st++] & 0xf); }
    if (neg) ref = -ref;
    return true;
  }
  template <typename T,
            typename enable_if<has_read<T>::value>::type * = nullptr>
  inline bool read_single(T &x) {
    x.read();
    return true;
  }
  bool read_single(double &ref) {
    string s;
    if (!read_single(s)) return false;
    ref = std::stod(s);
    return true;
  }
  bool read_single(char &ref) {
    string s;
    if (!read_single(s) || s.size() != 1) return false;
    ref = s[0];
    return true;
  }
  template <class T>
  bool read_single(vector<T> &ref) {
    for (auto &d: ref) {
      if (!read_single(d)) return false;
    }
    return true;
  }
  template <class T, class U>
  bool read_single(pair<T, U> &p) {
    return (read_single(p.first) && read_single(p.second));
  }
  template <size_t N = 0, typename T>
  void read_single_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
      auto &x = std::get<N>(t);
      read_single(x);
      read_single_tuple<N + 1>(t);
    }
  }
  template <class... T>
  bool read_single(tuple<T...> &tpl) {
    read_single_tuple(tpl);
    return true;
  }
  void read() {}
  template <class H, class... T>
  void read(H &h, T &... t) {
    bool f = read_single(h);
    assert(f);
    read(t...);
  }
  Scanner(FILE *fp) : fp(fp) {}
};

struct Printer {
  Printer(FILE *_fp) : fp(_fp) {}
  ~Printer() { flush(); }

  static constexpr size_t SIZE = 1 << 15;
  FILE *fp;
  char line[SIZE], small[50];
  size_t pos = 0;
  void flush() {
    fwrite(line, 1, pos, fp);
    pos = 0;
  }
  void write(const char val) {
    if (pos == SIZE) flush();
    line[pos++] = val;
  }
  template <class T, enable_if_t<is_integral<T>::value, int> = 0>
  void write(T val) {
    if (pos > (1 << 15) - 50) flush();
    if (val == 0) {
      write('0');
      return;
    }
    if (val < 0) {
      write('-');
      val = -val; // todo min
    }
    size_t len = 0;
    while (val) {
      small[len++] = char(0x30 | (val % 10));
      val /= 10;
    }
    for (size_t i = 0; i < len; i++) { line[pos + i] = small[len - 1 - i]; }
    pos += len;
  }
  void write(const string s) {
    for (char c: s) write(c);
  }
  void write(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++) write(s[i]);
  }
  void write(const double x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  void write(const long double x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << x;
    string s = oss.str();
    write(s);
  }
  template <typename T,
            typename enable_if<has_write<T>::value>::type * = nullptr>
  inline void write(T x) {
    x.write();
  }
  template <class T>
  void write(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  template <class T, class U>
  void write(const pair<T, U> val) {
    write(val.first);
    write(' ');
    write(val.second);
  }
  template <size_t N = 0, typename T>
  void write_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
      if constexpr (N > 0) { write(' '); }
      const auto x = std::get<N>(t);
      write(x);
      write_tuple<N + 1>(t);
    }
  }
  template <class... T>
  bool write(tuple<T...> tpl) {
    write_tuple(tpl);
    return true;
  }
  template <class T, size_t S>
  void write(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
      if (i) write(' ');
      write(val[i]);
    }
  }
  void write(i128 val) {
    string s;
    bool negative = 0;
    if (val < 0) {
      negative = 1;
      val = -val;
    }
    while (val) {
      s += '0' + int(val % 10);
      val /= 10;
    }
    if (negative) s += "-";
    reverse(all(s));
    if (len(s) == 0) s = "0";
    write(s);
  }
};
Scanner scanner = Scanner(stdin);
Printer printer = Printer(stdout);
void flush() { printer.flush(); }
void print() { printer.write('\n'); }
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
  printer.write(head);
  if (sizeof...(Tail)) printer.write(' ');
  print(forward<Tail>(tail)...);
}

void read() {}
template <class Head, class... Tail>
void read(Head &head, Tail &... tail) {
  scanner.read(head);
  read(tail...);
}
} // namespace fastio
using fastio::print;
using fastio::flush;
using fastio::read;

#define INT(...)   \
  int __VA_ARGS__; \
  read(__VA_ARGS__)
#define LL(...)   \
  ll __VA_ARGS__; \
  read(__VA_ARGS__)
#define STR(...)      \
  string __VA_ARGS__; \
  read(__VA_ARGS__)
#define CHAR(...)   \
  char __VA_ARGS__; \
  read(__VA_ARGS__)
#define DBL(...)      \
  double __VA_ARGS__; \
  read(__VA_ARGS__)

#define VEC(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define VV(type, name, h, w)                     \
  vector<vector<type>> name(h, vector<type>(w)); \
  read(name)

void YES(bool t = 1) { print(t ? "YES" : "NO"); }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { print(t ? "Yes" : "No"); }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { print(t ? "yes" : "no"); }
void no(bool t = 1) { yes(!t); }
#line 3 "main.cpp"

#line 2 "library/mod/modint_common.hpp"

struct has_mod_impl {
  template <class T>
  static auto check(T &&x) -> decltype(x.get_mod(), std::true_type{});
  template <class T>
  static auto check(...) -> std::false_type;
};

template <class T>
class has_mod : public decltype(has_mod_impl::check<T>(std::declval<T>())) {};


template <typename mint>
mint inv(int n) {
  static const int mod = mint::get_mod();
  static vector<mint> dat = {0, 1};
  assert(0 <= n);
  if (n >= mod) n %= mod;
  while (len(dat) <= n) {
    int k = len(dat);
    int q = (mod + k - 1) / k;
    dat.eb(dat[k * q - mod] * mint(q));
  }
  return dat[n];
}

template <typename mint>
mint fact(int n) {
  static const int mod = mint::get_mod();
  assert(0 <= n);
  if (n >= mod) return 0;
  static vector<mint> dat = {1, 1};
  while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * mint(len(dat)));
  return dat[n];
}

template <typename mint>
mint fact_inv(int n) {
  static const int mod = mint::get_mod();
  assert(-1 <= n && n < mod);
  static vector<mint> dat = {1, 1};
  if (n == -1) return mint(0);
  while (len(dat) <= n) dat.eb(dat[len(dat) - 1] * inv<mint>(len(dat)));
  return dat[n];
}

template <class mint, class... Ts>
mint fact_invs(Ts... xs) {
  return (mint(1) * ... * fact_inv<mint>(xs));
}

template <typename mint, class Head, class... Tail>
mint multinomial(Head &&head, Tail &&... tail) {
  return fact<mint>(head) * fact_invs<mint>(std::forward<Tail>(tail)...);
}

template <typename mint>
mint C_dense(int n, int k) {
  static vvc<mint> C;
  static int H = 0, W = 0;
  auto calc = [&](int i, int j) -> mint {
    if (i == 0) return (j == 0 ? mint(1) : mint(0));
    return C[i - 1][j] + (j ? C[i - 1][j - 1] : 0);
  };
  if (W <= k) {
    FOR(i, H) {
      C[i].resize(k + 1);
      FOR(j, W, k + 1) { C[i][j] = calc(i, j); }
    }
    W = k + 1;
  }
  if (H <= n) {
    C.resize(n + 1);
    FOR(i, H, n + 1) {
      C[i].resize(W);
      FOR(j, W) { C[i][j] = calc(i, j); }
    }
    H = n + 1;
  }
  return C[n][k];
}

template <typename mint, bool large = false, bool dense = false>
mint C(ll n, ll k) {
  assert(n >= 0);
  if (k < 0 || n < k) return 0;
  if (dense) return C_dense<mint>(n, k);
  if (!large) return multinomial<mint>(n, k, n - k);
  k = min(k, n - k);
  mint x(1);
  FOR(i, k) x *= mint(n - i);
  return x * fact_inv<mint>(k);
}

template <typename mint, bool large = false>
mint C_inv(ll n, ll k) {
  assert(n >= 0);
  assert(0 <= k && k <= n);
  if (!large) return fact_inv<mint>(n) * fact<mint>(k) * fact<mint>(n - k);
  return mint(1) / C<mint, 1>(n, k);
}

// [x^d] (1-x) ^ {-n} の計算
template <typename mint, bool large = false, bool dense = false>
mint C_negative(ll n, ll d) {
  assert(n >= 0);
  if (d < 0) return mint(0);
  if (n == 0) { return (d == 0 ? mint(1) : mint(0)); }
  return C<mint, large, dense>(n + d - 1, d);
}
#line 3 "library/mod/modint.hpp"

template <int mod>
struct modint {
  static_assert(mod < (1 << 30));
  int val;
  constexpr modint(const ll val = 0) noexcept
      : val(val >= 0 ? val % mod : (mod - (-val) % mod) % mod) {}
  bool operator<(const modint &other) const {
    return val < other.val;
  } // To use std::map
  modint &operator+=(const modint &p) {
    if ((val += p.val) >= mod) val -= mod;
    return *this;
  }
  modint &operator-=(const modint &p) {
    if ((val += mod - p.val) >= mod) val -= mod;
    return *this;
  }
  modint &operator*=(const modint &p) {
    val = (int)(1LL * val * p.val % mod);
    return *this;
  }
  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }
  modint operator-() const { return modint(-val); }
  modint operator+(const modint &p) const { return modint(*this) += p; }
  modint operator-(const modint &p) const { return modint(*this) -= p; }
  modint operator*(const modint &p) const { return modint(*this) *= p; }
  modint operator/(const modint &p) const { return modint(*this) /= p; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  modint inverse() const {
    int a = val, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b), swap(u -= t * v, v);
    }
    return modint(u);
  }
  modint pow(ll n) const {
    assert(n >= 0);
    modint ret(1), mul(val);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
#ifdef FASTIO
  void write() { fastio::printer.write(val); }
  void read() { fastio::scanner.read(val); }
#endif
  static constexpr int get_mod() { return mod; }
  // (n, r), r は 1 の 2^n 乗根
  static constexpr pair<int, int> ntt_info() {
    if (mod == 167772161) return {25, 17};
    if (mod == 469762049) return {26, 30};
    if (mod == 754974721) return {24, 362};
    if (mod == 880803841) return {23, 211};
    if (mod == 998244353) return {23, 31};
    if (mod == 1045430273) return {20, 363};
    if (mod == 1051721729) return {20, 330};
    if (mod == 1053818881) return {20, 2789};
    return {-1, -1};
  }
  static constexpr bool can_ntt() { return ntt_info().fi != -1; }
};

using modint107 = modint<1000000007>;
using modint998 = modint<998244353>;
#line 5 "main.cpp"

using mint = modint<1000000009>;

void solve() {
  LL(N);
  VEC(ll, A, N);
  sort(all(A));
  ll sm = A[0] + A.back();
  FOR(i, N) if (A[i] + A[N - 1 - i] != sm) return print(0);
  map<ll, ll> MP;
  FOR(i, N / 2) MP[A[i]]++;

  mint ANS = fact<mint>(N / 2);
  for (auto&& [a, b]: MP) ANS *= fact_inv<mint>(b);
  for (auto&& [a, b]: MP) {
    if (a != sm - a) { FOR(b) ANS += ANS; }
  }
  print(ANS);
}

signed main() {
  INT(T);
  FOR(T) solve();
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 3512kb

input:

5
3
2 3 1
4
1 1 1 1
3
1 2 4
7
0 200 0 200 50 100 150
14
-1 0 1 2 3 4 5 6 7 8 9 10 11 12

output:

2
1
0
24
645120

result:

ok 5 number(s): "2 1 0 24 645120"

Test #2:

score: 0
Accepted
time: 2ms
memory: 3356kb

input:

100
3
96 145 47
5
26 50 50 26 38
4
-60 -72 -60 -72
5
19 70 -32 117 -79
4
-34 -85 -11 -62
4
187 26 -85 76
2
22 -150
5
33 127 -61 -88 154
3
208 85 -38
3
-71 3 77
4
-78 90 -78 90
4
45 -41 -77 81
2
-93 85
3
-269 -100 69
5
-35 -31 -31 -33 -35
3
-91 -3 -47
4
-80 -82 42 44
2
-217 17
2
-56 74
5
-71 146 141 ...

output:

2
4
4
8
8
8
2
8
2
2
4
8
2
2
4
2
8
2
2
8
2
8
2
8
8
2
2
2
2
2
2
2
2
2
2
4
2
8
2
2
8
2
8
2
4
8
8
4
8
2
2
2
4
8
4
8
2
2
8
2
2
2
2
4
8
8
8
2
8
2
8
2
4
8
2
8
2
4
2
2
2
2
8
8
8
2
8
8
8
2
2
8
2
4
8
8
2
2
2
2

result:

ok 100 numbers

Test #3:

score: 0
Accepted
time: 2ms
memory: 3512kb

input:

100
6
620 -1224 -1224 -577 620 -27
6
2368 2266 788 -950 -848 630
6
-742 373 -1293 373 -1293 -178
9
313 863 -874 602 -1135 602 -874 -136 -585
7
-639 -331 73 -639 477 785 785
6
56 2521 -432 1768 -697 2256
8
-821 61 -183 -237 -679 329 398 -78
6
-2045 -2047 -437 987 -623 985
8
340 -934 988 -354 -313 408...

output:

24
48
24
192
24
48
0
48
384
48
3840
48
24
24
48
384
1920
384
384
192
48
48
24
64
8
1920
1920
960
1920
96
24
0
24
192
160
24
192
960
192
96
3840
48
64
48
640
384
24
48
24
0
3840
0
384
0
24
3840
384
384
0
96
48
0
192
64
0
24
192
24
3840
64
0
192
24
192
64
192
1920
48
640
192
1920
64
1920
192
384
64
0
...

result:

ok 100 numbers

Test #4:

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

input:

100
120
-114455311 -174718615 -37866982 -532413059 -97795839 -156986074 -433955847 -223791205 36013704 -128839659 -418460507 108469214 -141533155 -61323330 -374765855 -446611365 -363293792 -223791205 -360642838 130620126 -37866982 -174718615 -434523524 -374765855 -446611365 -199440556 141236146 3464...

output:

301557016
693667370
679308776
382295205
413760016
590145961
904245786
403834612
677442056
80470289
858160459
914072231
25248974
231559052
153817535
907768656
563481227
601280785
971106226
751059249
763721259
928947455
677434313
26701054
769219518
677880763
125068890
427310717
667323432
0
0
70980410
...

result:

ok 100 numbers

Test #5:

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

input:

100
349
4 -3 8 -5 6 3 3 12 10 -1 -2 0 0 -3 0 6 -1 3 6 9 12 10 3 3 11 6 -3 4 10 13 12 11 12 10 4 3 2 11 4 10 12 -2 -1 -2 4 -2 5 -4 6 10 3 -2 7 -2 13 5 3 12 5 4 5 9 -4 4 9 11 7 3 -3 12 -2 3 4 -1 9 9 6 9 5 3 3 10 7 4 1 1 -4 1 5 3 7 10 12 5 3 5 -5 12 11 1 3 4 4 -3 5 4 -3 -2 4 10 -1 9 4 10 4 -5 10 10 1 -...

output:

797334197
261650713
13452621
292658387
12
0
530220802
412900254
602693947
178048367
662937047
473322600
847468670
985503292
147033245
796944196
742110695
748501180
476456386
4480
15366259
100415968
96175861
160337120
884872249
0
632567605
54430517
0
5760
0
133556422
720513380
994746414
894268227
925...

result:

ok 100 numbers

Test #6:

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

input:

27
1000
-184054583 18950513 454533642 -173057958 339301016 -198317448 326966377 -140222777 -140222777 -184054583 384145165 -65361155 278937133 185812676 185812676 112074970 278937133 470945604 112074970 -65361155 -41413370 59125766 474850417 438110423 179925892 117961754 18950513 348345925 -14022277...

output:

110520192
735843216
513694224
740469570
2
174086022
587180293
1
513795966
447284518
176864924
425116607
63246314
1
750674059
387828424
741519055
816108292
431980043
369481989
2
740182541
337072795
1
83085379
312638265
503004

result:

ok 27 numbers

Test #7:

score: 0
Accepted
time: 49ms
memory: 6964kb

input:

1
500000
-35150664 144585927 169760595 -50559995 -22850504 109794846 188072608 -172822995 7347429 -17441834 14310102 154155174 -147341794 -123361554 72804482 44376266 112090757 -114685139 -62821805 27933970 -19669016 -123889172 37346259 -29714463 182774165 -53550750 -165268941 154185019 145369413 16...

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 26ms
memory: 10384kb

input:

1
500000
12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 12345 123...

output:

1

result:

ok 1 number(s): "1"

Test #9:

score: 0
Accepted
time: 99ms
memory: 17264kb

input:

1
500000
144603534 -89837766 1987286 165330109 19992331 -84670369 163455795 50871559 -139059922 112148990 -157611311 20814793 187916411 88090633 -13853193 -96438867 408247618 80217938 227938850 305424479 61983214 79161811 237287207 114755658 -80743762 340287746 71992958 157745372 -135527322 13699245...

output:

913387832

result:

ok 1 number(s): "913387832"

Test #10:

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

input:

1
500000
157514047 -42235989 203500526 -140641448 -16040598 44538676 -135560685 50342461 93134143 86299575 -122503542 -179301211 54704492 151455680 -2251861 -157377464 207867421 10359177 253318620 187202102 229503945 119850256 6889609 -93489109 100117003 17429625 110194795 180892801 -138432544 -9887...

output:

493838496

result:

ok 1 number(s): "493838496"

Test #11:

score: 0
Accepted
time: 109ms
memory: 17404kb

input:

1
500000
-159638317 270502828 -121352656 276965059 -184090959 89699787 463088147 484402481 338891394 -62720188 413238831 4549171 -124710021 369548680 282766650 134308879 170640349 185614116 199285770 -122011909 -87909101 26171382 124964768 312752562 273062537 463577547 333562209 349263346 416911814 ...

output:

694861705

result:

ok 1 number(s): "694861705"

Test #12:

score: 0
Accepted
time: 118ms
memory: 17296kb

input:

1
500000
-32838117 67728982 190597229 -132611918 -37703073 22101212 55589916 177161510 203513054 41527205 -8597577 -141799704 95208759 37847251 172919659 -23015366 -76578404 90346391 -40387515 232150729 -27461993 84506952 -113806848 -50379151 -91259613 226323228 178687236 133893671 1613412 94990382 ...

output:

102782842

result:

ok 1 number(s): "102782842"

Test #13:

score: 0
Accepted
time: 88ms
memory: 17396kb

input:

1
499999
-181939350 177047587 376374128 137325564 344635455 300099459 81705853 433327654 461694879 209066820 88973836 -160166963 -33415554 92935001 361965247 196069646 114952451 -66937255 -107534999 -8492839 154504109 -195309823 276473930 296943757 173552748 80936110 349206678 284720129 205529310 -4...

output:

750024497

result:

ok 1 number(s): "750024497"

Test #14:

score: 0
Accepted
time: 111ms
memory: 17456kb

input:

1
500000
-81516492 185829879 -287219514 -119866058 -147557964 60055880 50967632 -62571293 -96073475 59756839 -279906569 -164589116 -95559645 -28265329 -109476273 138093804 107568092 151317749 -27284649 -56866979 -285717104 -16186734 -8668345 -244070808 -271539022 -168032439 -34109554 22128483 -18691...

output:

563104622

result:

ok 1 number(s): "563104622"

Test #15:

score: 0
Accepted
time: 96ms
memory: 17312kb

input:

1
500000
74685816 132905522 52332400 27863103 -187528176 35501460 139043359 125298232 62738407 -149197098 114721173 -207012942 149998079 53715882 -67850635 56170381 -193026714 -99557881 -188957191 -76686098 1311785 43584368 -47521046 173907631 -155226304 -70716471 70916462 45776075 -62917358 -421892...

output:

498918353

result:

ok 1 number(s): "498918353"

Test #16:

score: 0
Accepted
time: 96ms
memory: 17388kb

input:

1
500000
127114539 279807925 213109115 174334015 307757171 -20167864 -173555000 40497025 124479960 124038075 -10661245 141205240 -42927309 283417167 12112958 93395923 349215911 192578324 173694208 11295226 80657446 67600454 -141548799 148083225 -4216721 160614942 139566436 -83036500 32116584 4616762...

output:

443357339

result:

ok 1 number(s): "443357339"

Test #17:

score: 0
Accepted
time: 102ms
memory: 17440kb

input:

1
499999
-244434376 -2816835 31905801 -173133860 13823536 66859305 -184516658 89746940 133879571 -38255438 97687435 -248521850 -123193526 126995946 -196253031 -74501420 -39525816 -72831091 -284638707 -90143971 -99476794 -77094643 -133604793 90694402 154965841 -132132096 -182436965 101251630 35827693...

output:

340694461

result:

ok 1 number(s): "340694461"

Test #18:

score: 0
Accepted
time: 116ms
memory: 17304kb

input:

1
500000
312193553 344205065 237720327 263837973 387732505 120904580 -76226754 -5669382 99145847 387722373 317184839 -117643072 105488194 177202657 -77456556 267234992 56270828 10184179 101917561 157037961 180517782 375399981 297669679 -61146160 5379485 108836755 175463548 185306330 245275368 -15521...

output:

838738574

result:

ok 1 number(s): "838738574"

Test #19:

score: 0
Accepted
time: 78ms
memory: 9592kb

input:

1
500000
-147041412 186559727 -22545111 -124509578 -110578695 60986661 -82024032 34917279 -156348403 66953770 19143334 -1679117 -129795280 -69872636 90428639 -197880855 -54717805 -11021835 7937595 -30518034 190847667 -184204078 56739377 25694532 -116575628 63753461 -81880708 -23193103 196003654 -191...

output:

286270253

result:

ok 1 number(s): "286270253"

Test #20:

score: 0
Accepted
time: 52ms
memory: 8160kb

input:

1
500000
-199283313 -186774128 -99431490 -153406109 107482790 -169729685 5095946 -14329909 -100075974 -99141187 67259227 -8109927 13892779 -59721330 -135750651 -30954745 -43005026 -151288994 -288866832 139765576 67333772 -146838483 -265052428 -36696652 27429367 136889662 -102448749 -21466950 -165153...

output:

29677003

result:

ok 1 number(s): "29677003"

Test #21:

score: 0
Accepted
time: 38ms
memory: 8052kb

input:

1
500000
-222063041 32058033 -36549483 740629 -148949822 -161839714 -35766411 -34676840 -66665918 182245586 -182185407 -54467092 -231734440 107512204 -143220910 -143376815 76191361 -134548903 -236108001 30769862 62549562 -246058856 87541933 -275364332 -104250420 109628747 100183621 -54361710 -131377...

output:

824022109

result:

ok 1 number(s): "824022109"

Test #22:

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

input:

1
500000
-305 -434 636 597 -619 -527 266 -640 392 -690 666 -170 531 540 -593 323 -523 569 -300 -491 426 -130 421 -609 -505 -607 172 -673 -594 -557 -93 207 -593 687 -464 -665 -353 344 -206 -581 -437 -560 -500 442 447 -652 -401 -535 678 -337 -472 668 607 -331 -664 -539 366 -275 436 516 -496 -336 547 -...

output:

255580629

result:

ok 1 number(s): "255580629"

Test #23:

score: 0
Accepted
time: 82ms
memory: 23656kb

input:

1
500000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

924782062

result:

ok 1 number(s): "924782062"