QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#243341#7761. 物理实验hos_lyric#100 ✓2320ms25008kbC++1414.5kb2023-11-08 04:17:582024-07-04 02:23:15

Judging History

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

  • [2024-07-04 02:23:15]
  • 评测
  • 测评结果:100
  • 用时:2320ms
  • 内存:25008kb
  • [2023-11-08 04:17:58]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")

////////////////////////////////////////////////////////////////////////////////
template <unsigned M_> struct ModInt {
  static constexpr unsigned M = M_;
  unsigned x;
  constexpr ModInt() : x(0U) {}
  constexpr ModInt(unsigned x_) : x(x_ % M) {}
  constexpr ModInt(unsigned long long x_) : x(x_ % M) {}
  constexpr ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
  constexpr ModInt(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
  ModInt &operator+=(const ModInt &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
  ModInt &operator-=(const ModInt &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
  ModInt &operator*=(const ModInt &a) { x = (static_cast<unsigned long long>(x) * a.x) % M; return *this; }
  ModInt &operator/=(const ModInt &a) { return (*this *= a.inv()); }
  ModInt pow(long long e) const {
    if (e < 0) return inv().pow(-e);
    ModInt a = *this, b = 1U; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
  }
  ModInt inv() const {
    unsigned a = M, b = x; int y = 0, z = 1;
    for (; b; ) { const unsigned q = a / b; const unsigned c = a - q * b; a = b; b = c; const int w = y - static_cast<int>(q) * z; y = z; z = w; }
    assert(a == 1U); return ModInt(y);
  }
  ModInt operator+() const { return *this; }
  ModInt operator-() const { ModInt a; a.x = x ? (M - x) : 0U; return a; }
  ModInt operator+(const ModInt &a) const { return (ModInt(*this) += a); }
  ModInt operator-(const ModInt &a) const { return (ModInt(*this) -= a); }
  ModInt operator*(const ModInt &a) const { return (ModInt(*this) *= a); }
  ModInt operator/(const ModInt &a) const { return (ModInt(*this) /= a); }
  template <class T> friend ModInt operator+(T a, const ModInt &b) { return (ModInt(a) += b); }
  template <class T> friend ModInt operator-(T a, const ModInt &b) { return (ModInt(a) -= b); }
  template <class T> friend ModInt operator*(T a, const ModInt &b) { return (ModInt(a) *= b); }
  template <class T> friend ModInt operator/(T a, const ModInt &b) { return (ModInt(a) /= b); }
  explicit operator bool() const { return x; }
  bool operator==(const ModInt &a) const { return (x == a.x); }
  bool operator!=(const ModInt &a) const { return (x != a.x); }
  friend std::ostream &operator<<(std::ostream &os, const ModInt &a) { return os << a.x; }
};
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
constexpr unsigned MO = 998244353U;
constexpr unsigned MO2 = 2U * MO;
constexpr int FFT_MAX = 23;
using Mint = ModInt<MO>;
constexpr Mint FFT_ROOTS[FFT_MAX + 1] = {1U, 998244352U, 911660635U, 372528824U, 929031873U, 452798380U, 922799308U, 781712469U, 476477967U, 166035806U, 258648936U, 584193783U, 63912897U, 350007156U, 666702199U, 968855178U, 629671588U, 24514907U, 996173970U, 363395222U, 565042129U, 733596141U, 267099868U, 15311432U};
constexpr Mint INV_FFT_ROOTS[FFT_MAX + 1] = {1U, 998244352U, 86583718U, 509520358U, 337190230U, 87557064U, 609441965U, 135236158U, 304459705U, 685443576U, 381598368U, 335559352U, 129292727U, 358024708U, 814576206U, 708402881U, 283043518U, 3707709U, 121392023U, 704923114U, 950391366U, 428961804U, 382752275U, 469870224U};
constexpr Mint FFT_RATIOS[FFT_MAX] = {911660635U, 509520358U, 369330050U, 332049552U, 983190778U, 123842337U, 238493703U, 975955924U, 603855026U, 856644456U, 131300601U, 842657263U, 730768835U, 942482514U, 806263778U, 151565301U, 510815449U, 503497456U, 743006876U, 741047443U, 56250497U, 867605899U};
constexpr Mint INV_FFT_RATIOS[FFT_MAX] = {86583718U, 372528824U, 373294451U, 645684063U, 112220581U, 692852209U, 155456985U, 797128860U, 90816748U, 860285882U, 927414960U, 354738543U, 109331171U, 293255632U, 535113200U, 308540755U, 121186627U, 608385704U, 438932459U, 359477183U, 824071951U, 103369235U};

// as[rev(i)] <- \sum_j \zeta^(ij) as[j]
void fft(Mint *as, int n) {
  assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << FFT_MAX);
  int m = n;
  if (m >>= 1) {
    for (int i = 0; i < m; ++i) {
      const unsigned x = as[i + m].x;  // < MO
      as[i + m].x = as[i].x + MO - x;  // < 2 MO
      as[i].x += x;  // < 2 MO
    }
  }
  if (m >>= 1) {
    Mint prod = 1U;
    for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
      for (int i = i0; i < i0 + m; ++i) {
        const unsigned x = (prod * as[i + m]).x;  // < MO
        as[i + m].x = as[i].x + MO - x;  // < 3 MO
        as[i].x += x;  // < 3 MO
      }
      prod *= FFT_RATIOS[__builtin_ctz(++h)];
    }
  }
  for (; m; ) {
    if (m >>= 1) {
      Mint prod = 1U;
      for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
        for (int i = i0; i < i0 + m; ++i) {
          const unsigned x = (prod * as[i + m]).x;  // < MO
          as[i + m].x = as[i].x + MO - x;  // < 4 MO
          as[i].x += x;  // < 4 MO
        }
        prod *= FFT_RATIOS[__builtin_ctz(++h)];
      }
    }
    if (m >>= 1) {
      Mint prod = 1U;
      for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
        for (int i = i0; i < i0 + m; ++i) {
          const unsigned x = (prod * as[i + m]).x;  // < MO
          as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x;  // < 2 MO
          as[i + m].x = as[i].x + MO - x;  // < 3 MO
          as[i].x += x;  // < 3 MO
        }
        prod *= FFT_RATIOS[__builtin_ctz(++h)];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x;  // < 2 MO
    as[i].x = (as[i].x >= MO) ? (as[i].x - MO) : as[i].x;  // < MO
  }
}

// as[i] <- (1/n) \sum_j \zeta^(-ij) as[rev(j)]
void invFft(Mint *as, int n) {
  assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << FFT_MAX);
  int m = 1;
  if (m < n >> 1) {
    Mint prod = 1U;
    for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
      for (int i = i0; i < i0 + m; ++i) {
        const unsigned long long y = as[i].x + MO - as[i + m].x;  // < 2 MO
        as[i].x += as[i + m].x;  // < 2 MO
        as[i + m].x = (prod.x * y) % MO;  // < MO
      }
      prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
    }
    m <<= 1;
  }
  for (; m < n >> 1; m <<= 1) {
    Mint prod = 1U;
    for (int h = 0, i0 = 0; i0 < n; i0 += (m << 1)) {
      for (int i = i0; i < i0 + (m >> 1); ++i) {
        const unsigned long long y = as[i].x + MO2 - as[i + m].x;  // < 4 MO
        as[i].x += as[i + m].x;  // < 4 MO
        as[i].x = (as[i].x >= MO2) ? (as[i].x - MO2) : as[i].x;  // < 2 MO
        as[i + m].x = (prod.x * y) % MO;  // < MO
      }
      for (int i = i0 + (m >> 1); i < i0 + m; ++i) {
        const unsigned long long y = as[i].x + MO - as[i + m].x;  // < 2 MO
        as[i].x += as[i + m].x;  // < 2 MO
        as[i + m].x = (prod.x * y) % MO;  // < MO
      }
      prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
    }
  }
  if (m < n) {
    for (int i = 0; i < m; ++i) {
      const unsigned y = as[i].x + MO2 - as[i + m].x;  // < 4 MO
      as[i].x += as[i + m].x;  // < 4 MO
      as[i + m].x = y;  // < 4 MO
    }
  }
  const Mint invN = Mint(n).inv();
  for (int i = 0; i < n; ++i) {
    as[i] *= invN;
  }
}

void fft(vector<Mint> &as) {
  fft(as.data(), as.size());
}
void invFft(vector<Mint> &as) {
  invFft(as.data(), as.size());
}

vector<Mint> convolve(vector<Mint> as, vector<Mint> bs) {
  if (as.empty() || bs.empty()) return {};
  const int len = as.size() + bs.size() - 1;
  int n = 1;
  for (; n < len; n <<= 1) {}
  as.resize(n); fft(as);
  bs.resize(n); fft(bs);
  for (int i = 0; i < n; ++i) as[i] *= bs[i];
  invFft(as);
  as.resize(len);
  return as;
}
vector<Mint> square(vector<Mint> as) {
  if (as.empty()) return {};
  const int len = as.size() + as.size() - 1;
  int n = 1;
  for (; n < len; n <<= 1) {}
  as.resize(n); fft(as);
  for (int i = 0; i < n; ++i) as[i] *= as[i];
  invFft(as);
  as.resize(len);
  return as;
}
////////////////////////////////////////////////////////////////////////////////


constexpr int LIM_INV = 400'010;
Mint inv[LIM_INV], fac[LIM_INV], invFac[LIM_INV];

void prepare() {
  inv[1] = 1;
  for (int i = 2; i < LIM_INV; ++i) {
    inv[i] = -((Mint::M / i) * inv[Mint::M % i]);
  }
  fac[0] = invFac[0] = 1;
  for (int i = 1; i < LIM_INV; ++i) {
    fac[i] = fac[i - 1] * i;
    invFac[i] = invFac[i - 1] * inv[i];
  }
}
Mint binom(Int n, Int k) {
  if (n < 0) {
    if (k >= 0) {
      return ((k & 1) ? -1 : +1) * binom(-n + k - 1, k);
    } else if (n - k >= 0) {
      return (((n - k) & 1) ? -1 : +1) * binom(-k - 1, n - k);
    } else {
      return 0;
    }
  } else {
    if (0 <= k && k <= n) {
      assert(n < LIM_INV);
      return fac[n] * invFac[k] * invFac[n - k];
    } else {
      return 0;
    }
  }
}


int N, M, L, R;
Mint P, Q;
vector<int> X;

vector<Mint> F;

vector<Mint> mul(const vector<Mint> &as, const vector<Mint> &bs) {
  auto cs = convolve(as, bs);
  for (int i = (int)cs.size(); --i >= 2 * M; ) cs[i - 2 * M] += cs[i];
  cs.resize(2 * M);
  return cs;
}
vector<Mint> power(vector<Mint> as, int e) {
  vector<Mint> bs(2 * M, 0);
  bs[0] = 1;
  for (; ; as = mul(as, as)) {
    if (e & 1) bs = mul(bs, as);
    if (!(e >>= 1)) return bs;
  }
}


namespace brute {
vector<Mint> run() {
cerr<<"[brute::run]"<<endl;
  vector<Mint> ans;
  auto fs = F;
  for (int t = 1; t <= R; ++t) {
    vector<Mint> gs(M + 1, 0);
    gs[0] += fs[0];
    gs[M] += fs[M];
    for (int i = 1; i < M; ++i) {
      gs[i - 1] += fs[i] * Q;
      gs[i] += fs[i] * (1 - 2 * Q);
      gs[i + 1] += fs[i] * Q;
    }
    fs = gs;
    if (L <= t && t <= R) {
      Mint sum = 0;
      for (int i = 0; i <= M; ++i) {
        sum += fs[i] * min(i, M - i);
      }
      ans.push_back(sum);
    }
  }
  return ans;
}
}  // brute


namespace single {
vector<Mint> run() {
cerr<<"[single::run]"<<endl;
  vector<Mint> fs(2 * M, 0);
  for (int i = 1; i < M; ++i) {
    fs[i] += F[i];
    fs[2 * M - i] -= F[i];
  }
  vector<Mint> qs(2 * M, 0);
  qs[0] = 1 - 2 * Q;
  qs[1] = qs[2 * M - 1] = Q;
  const auto gs = mul(fs, power(qs, R));
  Mint ans = 0;
  for (int i = 1; i < M; ++i) {
    ans += gs[i] * min(i, M - i);
  }
  return {ans};
}
}  // single


namespace fast {
int mod(int x) {
  return ((x %= (2 * M)) < 0) ? (x + (2 * M)) : x;
}

vector<Mint> ans;
void add(int l, int r, Mint val) {
  ans[l] += val;
  ans[r] -= val;
}

// +1 or -1
void solve(int l, int r, int off, vector<Mint> fs) {
// cerr<<"solve "<<l<<" "<<r<<" "<<off<<" "<<fs<<endl;
  if ((int)fs.size() >= 2 * M) {
    for (int i = (int)fs.size(); --i >= 2 * M; ) {
      fs[i - 2 * M] += fs[i];
    }
    fs.resize(2 * M);
  }
  const int fsLen = fs.size();
  const int d = r - l - 1;
  vector<int> is;
  is.push_back(-1);
  for (int i = 0; i < fsLen; ++i) {
    const int x = mod(off + i);
    if (0 <= x - d && x + d <= M/2) {
      is.push_back(i);
      add(l, r, fs[i] * x);
    } else if (M - M/2 <= x - d && x + d <= M) {
      is.push_back(i);
      add(l, r, fs[i] * (M - x));
    } else if (M <= x - d && x + d <= 2 * M) {
      is.push_back(i);
    } else {
      //
    }
  }
  is.push_back(fsLen);
  if (l + 1 < r) {
    const int mid = (l + r) / 2;
    const int half = mid - l;
    const Mint two = Mint(2).pow(-half);
    vector<Mint> coef(min(2 * half + 1, 2 * M), 0);
    for (int i = 0; i <= half; ++i) coef[(2 * i) % (2 * M)] += binom(half, i) * two;
    const int isLen = is.size();
    for (int j = 0; j < isLen - 1; ++j) if (is[j] + 1 < is[j + 1]) {
      const vector<Mint> gs(fs.begin() + (is[j] + 1), fs.begin() + is[j + 1]);
      solve(l, mid, off + (is[j] + 1), gs);
      solve(mid, r, off + (is[j] + 1) - half, convolve(gs, coef));
    }
  }
}

vector<Mint> run() {
cerr<<"[fast::run]"<<endl;
  vector<Mint> fs(2 * M, 0);
  for (int i = 1; i < M; ++i) {
    fs[i] += F[i];
    fs[2 * M - i] -= F[i];
  }
  vector<Mint> qs(2 * M, 0);
  qs[0] = 1 - 2 * Q;
  qs[1] = qs[2 * M - 1] = Q;
  fs = mul(fs, power(qs, L));
  
  const int len = R - L + 1;
  ans.assign(len + 1, 0);
  solve(0, len, 0, fs);
  for (int i = 0; i < len; ++i) ans[i + 1] += ans[i];
  assert(!ans.back());
  ans.pop_back();
  {
    Mint pw = 1;
    for (int i = 0; i < len; ++i) {
      ans[i] *= invFac[i] * pw;
      pw *= (2 * Q);
    }
  }
  // 0
  vector<Mint> coef(len);
  {
    Mint pw = 1;
    for (int i = 0; i < len; ++i) {
      coef[i] = invFac[i] * pw;
      pw *= (1 - 2 * Q);
    }
  }
  ans = convolve(ans, coef);
  ans.resize(len);
  for (int i = 0; i < len; ++i) {
    ans[i] *= fac[i];
  }
  return ans;
}
}  // fast


int main() {
  prepare();
  
  for (; ~scanf("%d%d%u%d%d", &N, &M, &P.x, &L, &R); ) {
    X.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d", &X[i]);
    }
    
    Q = P * (1 - P);
    
    {
      vector<Mint> fs(M + 1, 0), fsRev(M + 1, 0);
      for (int i = 0; i < N; ++i) {
        fs[X[i]] += 1;
        fsRev[M - X[i]] += 1;
      }
      const auto prod = convolve(fs, fsRev);
      F.assign(M + 1, 0);
      for (int i = 0; i <= M; ++i) {
        F[i] += prod[M + i];
      }
      F[0] -= N;
    }
// cerr<<"F = "<<F<<endl;
    
    const auto ans = fast::run();
    for (int h = 0; h < (int)ans.size(); ++h) {
      if (h) printf(" ");
      printf("%u", ans[h].x);
    }
    puts("");
  }
  return 0;
}

详细

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 55ms
memory: 9284kb

input:

7500 7500 96132844 1 7500
1791 817 5559 4742 5272 3988 6672 1355 2783 5552 6885 5321 5996 6495 3072 2241 5527 856 6250 2741 4223 1560 6529 5330 3517 2637 6577 244 1739 5147 2648 6466 1479 7340 7355 176 183 1417 2943 5134 3879 3574 734 4880 7451 3778 1466 5237 2015 1334 6105 4859 1331 5805 3175 4795 ...

output:

107146521 488242901 833543364 942893118 320285439 306745340 85380418 480027337 540734953 491950738 458848527 302817505 548924517 963679504 322777659 657420416 538451400 200569821 907146642 940780727 947566362 523285833 942400409 151786157 800926749 797312944 150412848 483203343 637066163 296999542 7...

result:

ok 7500 numbers

Test #2:

score: 0
Accepted
time: 54ms
memory: 9300kb

input:

7500 7499 673240178 1 7499
5325 2885 1225 7126 4988 4269 658 4221 3543 5162 3938 4780 143 2660 6991 5150 5888 6531 6373 6826 2873 5241 5052 793 5475 6299 3991 2399 5665 3786 7339 2749 1696 2681 583 936 5639 6299 4560 3177 6767 3089 4368 4458 650 6558 504 6277 5953 486 6093 1002 7466 5944 952 1796 26...

output:

109401794 751123382 342076416 876406297 327121602 311591650 658676729 820335019 101216944 433427180 230881034 816626094 344216982 198597590 550358617 514078855 683479653 690443997 798617649 473086234 4628208 388804376 899390057 607945374 81999043 497907004 96630466 310290755 759301009 878290881 3611...

result:

ok 7499 numbers

Subtask #2:

score: 5
Accepted

Dependency #1:

100%
Accepted

Test #3:

score: 5
Accepted
time: 63ms
memory: 9652kb

input:

100000 7500 118222194 1 7500
3879 2242 3106 4127 506 5025 480 5913 2013 3740 650 2202 1577 2978 6555 6199 5338 381 936 7430 993 4028 5741 6540 6422 4252 2131 7437 5068 987 4811 7124 6065 6410 2109 6632 1991 995 78 4504 4427 2610 5727 3929 1822 1439 1017 4818 7129 5473 5854 3349 5040 4434 7465 3155 1...

output:

282177948 793195087 371410272 216302166 754838287 635906627 439235084 549238170 147552281 407585707 39424623 564372511 864932973 510959225 287498668 535739056 868188763 901535442 654683909 226988238 902028211 161262841 221883186 568157461 482406651 216671554 376345332 170647927 14316551 761201715 90...

result:

ok 7500 numbers

Test #4:

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

input:

100000 7499 747110152 1 7499
5187 1708 2112 4578 2265 288 4560 2351 944 4258 6394 3390 697 4182 532 833 82 3658 533 5870 5590 3592 6478 144 3929 4926 1845 2566 1063 4570 4748 5802 34 1128 876 3815 2323 4979 1508 4139 4002 4135 5945 611 1844 2457 6689 3266 6857 6852 2214 3486 5429 5273 1659 3586 7195...

output:

66587322 285203560 2811948 574520751 858297444 536639754 74432038 182648309 281510238 841004083 735652999 528557891 469508052 915681980 763925994 45174777 229418630 803369770 610703721 893113152 894067444 913745695 914305706 556012225 267456134 482474991 686056644 746085405 285733366 751933635 95587...

result:

ok 7499 numbers

Subtask #3:

score: 10
Accepted

Test #5:

score: 10
Accepted
time: 75ms
memory: 9264kb

input:

100000 7500 500440646 935892941 935892941
3280 7218 1216 489 4036 7029 5538 4805 2544 568 4303 816 739 2284 1294 6062 808 3029 3565 4344 7124 3917 705 3637 6076 2019 4233 2032 7327 5672 2872 2593 22 1534 2071 5782 3228 5460 1217 5138 7285 3679 2751 213 2242 2673 2746 7041 7001 860 2591 7347 3330 213...

output:

768801558

result:

ok 1 number(s): "768801558"

Test #6:

score: 0
Accepted
time: 76ms
memory: 9196kb

input:

100000 7499 356847081 883948227 883948227
549 2423 3380 3811 4666 3645 5857 7184 7137 861 2619 519 409 1607 2298 7164 2216 2856 6790 6857 405 1928 5391 2949 6345 4839 2372 2974 4699 2688 6768 684 2012 3642 6225 6948 5313 6936 876 38 3004 7440 4671 208 4906 4714 7067 3424 3163 6165 115 4974 2178 4613...

output:

701047464

result:

ok 1 number(s): "701047464"

Subtask #4:

score: 15
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #7:

score: 15
Accepted
time: 824ms
memory: 13340kb

input:

100000 7500 324870432 583103598 583203597
2819 6279 3295 3707 2120 6990 14 1246 3567 6766 4198 4413 2123 5272 6818 7182 6920 287 2185 5195 5539 6080 2986 1536 1159 3669 2790 3383 1417 768 3646 7228 1888 1231 2202 2896 472 1958 5142 3740 5892 378 6359 7270 7407 2208 4685 5740 3022 2649 1295 5114 2256...

output:

740225554 688730085 666338385 475276155 807064812 500095659 44309318 861772879 78356182 988358620 585724905 640424989 556057537 35424100 767966489 880447110 762909851 944339643 717703315 580178270 484495737 516036394 173065791 387258514 936550519 895732005 888643466 153736055 198030515 42309462 7892...

result:

ok 100000 numbers

Test #8:

score: 0
Accepted
time: 835ms
memory: 13684kb

input:

100000 7499 630543739 241932849 242032848
501 910 423 2058 6677 2965 5408 5680 3673 2582 5674 3945 6662 6669 5390 3600 6128 2874 3694 3702 6779 6604 6079 5505 2311 3671 4824 4653 699 3240 6174 5130 5060 7175 3448 5470 6804 2594 2766 3609 5041 3162 6459 4693 540 1051 2084 5495 5715 1474 668 1217 3525...

output:

633608521 78518409 282090790 7883019 256910681 101897243 255895014 370356142 570297806 913428964 313184022 540665339 429163505 78289603 950233320 684974444 894229044 439189457 289387477 996682288 970455571 301701443 936585230 465151269 3458883 412009636 967020579 569371310 680578235 121138004 650394...

result:

ok 100000 numbers

Subtask #5:

score: 15
Accepted

Test #9:

score: 15
Accepted
time: 278ms
memory: 14620kb

input:

100000 50000 559705157 50000 50000
27437 48841 4744 41269 30017 24703 22660 38617 9707 42083 31500 14053 45335 20769 16455 30887 31847 6833 44822 14557 15400 18868 15093 47184 35490 48961 45686 45613 297 31598 7021 9194 30432 14570 44495 39114 21800 16034 12668 49738 20083 31717 22713 34958 46363 35...

output:

397469689

result:

ok 1 number(s): "397469689"

Test #10:

score: 0
Accepted
time: 311ms
memory: 14720kb

input:

100000 49999 86745154 49997 49997
48426 40553 19077 46485 43804 17022 31056 13627 31226 10367 13637 44826 33994 23159 9781 40172 19370 28896 31766 935 6943 7363 19203 27692 39512 28209 3294 33567 40851 19398 34866 35532 30821 43403 26783 26807 38940 48872 23076 40143 45338 36152 20857 38807 43963 49...

output:

785463309

result:

ok 1 number(s): "785463309"

Subtask #6:

score: 15
Accepted

Dependency #2:

100%
Accepted

Dependency #5:

100%
Accepted

Test #11:

score: 15
Accepted
time: 522ms
memory: 16508kb

input:

100000 50000 799022751 1 50000
6127 37738 3322 30488 14059 41183 40655 527 40437 41308 26035 11159 17054 31523 41372 12724 40510 17809 24956 2478 14840 31523 39246 2098 35444 14693 43715 42208 31806 7186 33566 26842 17243 5147 31608 8099 24527 33767 18091 4559 7237 41097 13970 41388 25507 28832 9301...

output:

132298708 289047527 413447876 781778083 97895915 354838554 373266509 474787763 904036000 813722146 843484762 415606237 533498887 930349098 704619403 673038488 109538015 93010067 888452800 163046576 30149614 856437369 36887965 106658775 435089813 41946768 510208922 805289347 221829020 659693012 69972...

result:

ok 50000 numbers

Test #12:

score: 0
Accepted
time: 519ms
memory: 16584kb

input:

100000 49999 217786593 1 49999
11134 7341 21307 22274 13049 21797 36199 39081 39673 3190 40216 28592 16186 32013 44505 23600 32539 47609 1505 47314 40800 38278 25325 3402 14013 24465 11454 33321 21873 37718 17675 41068 30879 9256 9464 42967 8396 17284 12299 25568 11672 2598 16122 8669 17828 9481 254...

output:

691735588 625397830 489535352 626048653 191551463 28522317 347624460 235411497 614975917 687878009 223580833 519815492 411389466 57261434 30154411 543953694 114461641 363949829 399661685 127825058 279202425 27951399 165971804 415219491 802295076 454071120 272513357 275765270 685745481 659969589 9651...

result:

ok 49999 numbers

Subtask #7:

score: 5
Accepted

Dependency #3:

100%
Accepted

Dependency #5:

100%
Accepted

Test #13:

score: 5
Accepted
time: 549ms
memory: 14720kb

input:

100000 50000 116210524 739331537 739331537
28468 1684 43774 20012 16143 30422 26320 37470 18602 45764 9197 38675 11335 27052 37930 43558 38514 33720 36786 38149 12759 25898 29143 2671 47186 19877 19582 43378 16434 38070 37702 34232 24160 26875 14303 18186 6218 46623 41768 774 25988 12859 39939 9327 ...

output:

568504960

result:

ok 1 number(s): "568504960"

Test #14:

score: 0
Accepted
time: 581ms
memory: 14632kb

input:

100000 49999 838141856 974772137 974772137
12398 11958 19317 41187 48622 10113 28135 30927 4722 15323 37359 14284 4941 3540 46847 36704 6686 44955 29141 1546 945 42278 22876 48424 2519 46807 36818 19133 27934 45030 42377 36609 43243 2201 5986 36346 36683 5568 38112 33025 5690 2352 45838 42477 12959 ...

output:

573389237

result:

ok 1 number(s): "573389237"

Subtask #8:

score: 10
Accepted

Dependency #7:

100%
Accepted

Test #15:

score: 10
Accepted
time: 1164ms
memory: 21052kb

input:

100000 100000 187748990 613573870 613573870
98286 9398 93591 63433 65397 2084 94309 66738 9828 86362 42304 91596 20320 24261 99837 55266 2704 95755 44187 42056 5011 63865 47214 36791 11658 57641 48212 33208 99844 62177 43723 36732 65162 52978 60255 25999 32926 41172 22088 84345 96206 63169 47386 770...

output:

602817796

result:

ok 1 number(s): "602817796"

Test #16:

score: 0
Accepted
time: 1187ms
memory: 20960kb

input:

100000 99999 50496054 533806148 533806148
87381 3252 39269 96687 14123 42131 4056 34376 1333 5719 61225 15637 76409 22015 67476 14666 12999 76239 96322 24189 92459 87856 14475 50321 50062 76065 75381 10556 5794 50168 58290 24290 61555 98937 28946 42169 36726 4937 78250 46542 50606 91642 87254 24356 ...

output:

175390926

result:

ok 1 number(s): "175390926"

Subtask #9:

score: 10
Accepted

Dependency #6:

100%
Accepted

Dependency #7:

100%
Accepted

Test #17:

score: 10
Accepted
time: 986ms
memory: 16420kb

input:

100000 50000 515372256 805622672 805672671
46130 27382 28980 45723 6421 31628 44713 48188 39883 2097 41472 42967 34690 28916 26200 19156 2654 24603 21886 26163 24585 41251 23422 39477 19751 39766 41005 22820 38004 9154 24990 37045 28907 7818 21617 19469 31762 13720 23630 26794 43906 11467 1372 28107...

output:

593018140 988974634 273462381 240578099 461419467 238655315 109747192 211183458 68504822 564253366 238180780 289369472 540025812 882382126 977501138 683539567 252152866 269172753 179246203 137480186 947105140 852991573 81236874 179356934 162628612 843143044 540913527 445796297 733538847 855670928 11...

result:

ok 50000 numbers

Test #18:

score: 0
Accepted
time: 996ms
memory: 16744kb

input:

100000 49999 698077452 303097059 303147058
9848 39544 12409 13079 1157 38521 48314 24652 679 9088 4459 2359 45594 44638 19260 48921 21618 21649 4512 10399 36957 13606 28723 30248 35959 13941 22817 29814 1720 42060 20870 29286 31155 26667 3569 38851 20189 20754 31796 40991 40047 12671 1125 16349 1702...

output:

360129656 172735569 215366505 576053793 384729703 45171390 432458281 87402545 701494764 314045383 77943276 227242430 902247433 802040895 732109130 190033369 997922325 972564033 760048161 198746951 187164931 374011148 833400326 453874247 439331646 686793021 66815645 338227093 667271453 628120730 1206...

result:

ok 50000 numbers

Test #19:

score: 0
Accepted
time: 690ms
memory: 13732kb

input:

100000 20000 624025069 441466031 441516030
13035 1701 708 2203 11556 8031 2431 2017 991 9737 11980 17051 4515 6001 16039 5627 7422 13077 7083 11454 14812 2616 7454 10890 14773 7624 6879 5337 12624 15958 7921 9511 10544 9998 19823 6331 17531 9848 8864 5268 7494 90 11885 11329 11311 4082 449 8498 1115...

output:

444650536 205527497 252681699 288415912 592501149 766262177 103400556 741961762 547579071 825227120 289608759 634515460 172571688 94959429 506726462 525590137 6858786 645007293 230030897 530291783 471804047 377073589 461625882 467512314 213536333 390094559 774376506 59893977 341961894 462039574 2090...

result:

ok 50000 numbers

Subtask #10:

score: 10
Accepted

Dependency #4:

100%
Accepted

Dependency #8:

100%
Accepted

Dependency #9:

100%
Accepted

Test #20:

score: 10
Accepted
time: 2320ms
memory: 25008kb

input:

100000 100000 928834876 527785558 527885557
20783 73372 19963 43042 67647 13928 55804 58326 88716 69012 48824 91533 18158 99022 8208 54362 74102 53761 34757 3660 54646 78335 36414 29358 79768 51019 83014 56435 50894 66419 75905 46815 9685 4754 37196 71316 18518 20787 79511 27681 19694 44114 59539 46...

output:

766266376 828295420 816003361 302459833 940536268 677486854 896205796 585375441 191702182 598808804 420222049 344163913 558743363 555216618 594901086 198615900 362495600 804045131 762848587 184864148 57484427 566101422 26322153 952298578 743380649 478462180 122218543 526630704 426164047 134029479 25...

result:

ok 100000 numbers

Test #21:

score: 0
Accepted
time: 2177ms
memory: 24976kb

input:

100000 99999 726401567 907266593 907366592
97779 96845 22864 28265 84089 80467 55717 7400 69509 43853 19336 67451 75404 32946 50552 41906 20140 17324 89294 90628 99109 90030 32784 20280 77723 15956 39786 12476 86617 50455 26812 46534 2271 63442 66768 44964 2839 46252 15588 18937 96490 48226 41922 56...

output:

581619038 950699337 571643288 250766090 894141099 236712474 944207595 818370737 948503652 190567633 305024075 209211840 880526588 890790013 498605549 549023832 135097782 202695303 616932681 200750872 443973849 630142771 569658158 303430305 499451015 153921726 389588338 567370029 648905938 242049628 ...

result:

ok 100000 numbers

Test #22:

score: 0
Accepted
time: 1180ms
memory: 15884kb

input:

100000 30000 634060505 153669081 153769080
16289 5257 13500 16274 22642 25134 27096 390 4730 29431 11267 1953 17757 25487 12690 8900 29236 28069 12888 24805 18826 800 14135 29140 596 22046 9790 4514 12546 25759 14103 933 7410 21434 19294 26584 14941 22442 11540 4198 23764 291 25073 12940 6837 29785 ...

output:

925585512 454308485 626332474 81469213 722703145 424189396 749135116 675105072 559533213 382104176 813473244 768998728 223813529 941553822 403616446 335174988 118990861 973913315 903426941 853872721 860083454 374039629 941454071 905872243 644345559 153556682 266494189 576375481 796522228 210467596 4...

result:

ok 100000 numbers