QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#621071 | #9448. Product Matrix | hos_lyric | AC ✓ | 875ms | 210040kb | C++14 | 17.4kb | 2024-10-08 05:39:21 | 2024-10-08 05:39:21 |
Judging History
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; }
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// M: prime, G: primitive root, 2^K | M - 1
template <unsigned M_, unsigned G_, int K_> struct Fft {
static_assert(2U <= M_, "Fft: 2 <= M must hold.");
static_assert(M_ < 1U << 30, "Fft: M < 2^30 must hold.");
static_assert(1 <= K_, "Fft: 1 <= K must hold.");
static_assert(K_ < 30, "Fft: K < 30 must hold.");
static_assert(!((M_ - 1U) & ((1U << K_) - 1U)), "Fft: 2^K | M - 1 must hold.");
static constexpr unsigned M = M_;
static constexpr unsigned M2 = 2U * M_;
static constexpr unsigned G = G_;
static constexpr int K = K_;
ModInt<M> FFT_ROOTS[K + 1], INV_FFT_ROOTS[K + 1];
ModInt<M> FFT_RATIOS[K], INV_FFT_RATIOS[K];
Fft() {
const ModInt<M> g(G);
for (int k = 0; k <= K; ++k) {
FFT_ROOTS[k] = g.pow((M - 1U) >> k);
INV_FFT_ROOTS[k] = FFT_ROOTS[k].inv();
}
for (int k = 0; k <= K - 2; ++k) {
FFT_RATIOS[k] = -g.pow(3U * ((M - 1U) >> (k + 2)));
INV_FFT_RATIOS[k] = FFT_RATIOS[k].inv();
}
assert(FFT_ROOTS[1] == M - 1U);
}
// as[rev(i)] <- \sum_j \zeta^(ij) as[j]
void fft(ModInt<M> *as, int n) const {
assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << K);
int m = n;
if (m >>= 1) {
for (int i = 0; i < m; ++i) {
const unsigned x = as[i + m].x; // < M
as[i + m].x = as[i].x + M - x; // < 2 M
as[i].x += x; // < 2 M
}
}
if (m >>= 1) {
ModInt<M> 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; // < M
as[i + m].x = as[i].x + M - x; // < 3 M
as[i].x += x; // < 3 M
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
for (; m; ) {
if (m >>= 1) {
ModInt<M> 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; // < M
as[i + m].x = as[i].x + M - x; // < 4 M
as[i].x += x; // < 4 M
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
if (m >>= 1) {
ModInt<M> 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; // < M
as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x; // < 2 M
as[i + m].x = as[i].x + M - x; // < 3 M
as[i].x += x; // < 3 M
}
prod *= FFT_RATIOS[__builtin_ctz(++h)];
}
}
}
for (int i = 0; i < n; ++i) {
as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x; // < 2 M
as[i].x = (as[i].x >= M) ? (as[i].x - M) : as[i].x; // < M
}
}
// as[i] <- (1/n) \sum_j \zeta^(-ij) as[rev(j)]
void invFft(ModInt<M> *as, int n) const {
assert(!(n & (n - 1))); assert(1 <= n); assert(n <= 1 << K);
int m = 1;
if (m < n >> 1) {
ModInt<M> 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 + M - as[i + m].x; // < 2 M
as[i].x += as[i + m].x; // < 2 M
as[i + m].x = (prod.x * y) % M; // < M
}
prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
}
m <<= 1;
}
for (; m < n >> 1; m <<= 1) {
ModInt<M> 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 + M2 - as[i + m].x; // < 4 M
as[i].x += as[i + m].x; // < 4 M
as[i].x = (as[i].x >= M2) ? (as[i].x - M2) : as[i].x; // < 2 M
as[i + m].x = (prod.x * y) % M; // < M
}
for (int i = i0 + (m >> 1); i < i0 + m; ++i) {
const unsigned long long y = as[i].x + M - as[i + m].x; // < 2 M
as[i].x += as[i + m].x; // < 2 M
as[i + m].x = (prod.x * y) % M; // < M
}
prod *= INV_FFT_RATIOS[__builtin_ctz(++h)];
}
}
if (m < n) {
for (int i = 0; i < m; ++i) {
const unsigned y = as[i].x + M2 - as[i + m].x; // < 4 M
as[i].x += as[i + m].x; // < 4 M
as[i + m].x = y; // < 4 M
}
}
const ModInt<M> invN = ModInt<M>(n).inv();
for (int i = 0; i < n; ++i) {
as[i] *= invN;
}
}
void fft(vector<ModInt<M>> &as) const {
fft(as.data(), as.size());
}
void invFft(vector<ModInt<M>> &as) const {
invFft(as.data(), as.size());
}
vector<ModInt<M>> convolve(vector<ModInt<M>> as, vector<ModInt<M>> bs) const {
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<ModInt<M>> square(vector<ModInt<M>> as) const {
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;
}
// cs[k] = \sum[i-j=k] as[i] bs[j] (0 <= k <= m-n)
vector<ModInt<M>> middle(vector<ModInt<M>> as, vector<ModInt<M>> bs) const {
const int m = as.size(), n = bs.size();
assert(m >= n); assert(n >= 1);
int len = 1;
for (; len < m; len <<= 1) {}
as.resize(len, 0);
fft(as);
std::reverse(bs.begin(), bs.end());
bs.resize(len, 0);
fft(bs);
for (int i = 0; i < len; ++i) as[i] *= bs[i];
invFft(as);
as.resize(m);
as.erase(as.begin(), as.begin() + (n - 1));
return as;
}
};
// M0 M1 M2 = 789204840662082423367925761 (> 7.892 * 10^26, > 2^89)
// M0 M3 M4 M5 M6 = 797766583174034668024539679147517452591562753 (> 7.977 * 10^44, > 2^149)
const Fft<998244353U, 3U, 23> FFT0;
const Fft<897581057U, 3U, 23> FFT1;
const Fft<880803841U, 26U, 23> FFT2;
const Fft<985661441U, 3U, 22> FFT3;
const Fft<943718401U, 7U, 22> FFT4;
const Fft<935329793U, 3U, 22> FFT5;
const Fft<918552577U, 5U, 22> FFT6;
// T = unsigned, unsigned long long, ModInt<M>
template <class T, unsigned M0, unsigned M1, unsigned M2>
T garner(ModInt<M0> a0, ModInt<M1> a1, ModInt<M2> a2) {
static const ModInt<M1> INV_M0_M1 = ModInt<M1>(M0).inv();
static const ModInt<M2> INV_M0M1_M2 = (ModInt<M2>(M0) * M1).inv();
const ModInt<M1> b1 = INV_M0_M1 * (a1 - a0.x);
const ModInt<M2> b2 = INV_M0M1_M2 * (a2 - (ModInt<M2>(b1.x) * M0 + a0.x));
return (T(b2.x) * M1 + b1.x) * M0 + a0.x;
}
template <class T, unsigned M0, unsigned M1, unsigned M2, unsigned M3, unsigned M4>
T garner(ModInt<M0> a0, ModInt<M1> a1, ModInt<M2> a2, ModInt<M3> a3, ModInt<M4> a4) {
static const ModInt<M1> INV_M0_M1 = ModInt<M1>(M0).inv();
static const ModInt<M2> INV_M0M1_M2 = (ModInt<M2>(M0) * M1).inv();
static const ModInt<M3> INV_M0M1M2_M3 = (ModInt<M3>(M0) * M1 * M2).inv();
static const ModInt<M4> INV_M0M1M2M3_M4 = (ModInt<M4>(M0) * M1 * M2 * M3).inv();
const ModInt<M1> b1 = INV_M0_M1 * (a1 - a0.x);
const ModInt<M2> b2 = INV_M0M1_M2 * (a2 - (ModInt<M2>(b1.x) * M0 + a0.x));
const ModInt<M3> b3 = INV_M0M1M2_M3 * (a3 - ((ModInt<M3>(b2.x) * M1 + b1.x) * M0 + a0.x));
const ModInt<M4> b4 = INV_M0M1M2M3_M4 * (a4 - (((ModInt<M4>(b3.x) * M2 + b2.x) * M1 + b1.x) * M0 + a0.x));
return (((T(b4.x) * M3 + b3.x) * M2 + b2.x) * M1 + b1.x) * M0 + a0.x;
}
template <unsigned M> vector<ModInt<M>> convolve(const vector<ModInt<M>> &as, const vector<ModInt<M>> &bs) {
static constexpr unsigned M0 = decltype(FFT0)::M;
static constexpr unsigned M1 = decltype(FFT1)::M;
static constexpr unsigned M2 = decltype(FFT2)::M;
if (as.empty() || bs.empty()) return {};
const int asLen = as.size(), bsLen = bs.size();
vector<ModInt<M0>> as0(asLen), bs0(bsLen);
for (int i = 0; i < asLen; ++i) as0[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs0[i] = bs[i].x;
const vector<ModInt<M0>> cs0 = FFT0.convolve(as0, bs0);
vector<ModInt<M1>> as1(asLen), bs1(bsLen);
for (int i = 0; i < asLen; ++i) as1[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs1[i] = bs[i].x;
const vector<ModInt<M1>> cs1 = FFT1.convolve(as1, bs1);
vector<ModInt<M2>> as2(asLen), bs2(bsLen);
for (int i = 0; i < asLen; ++i) as2[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs2[i] = bs[i].x;
const vector<ModInt<M2>> cs2 = FFT2.convolve(as2, bs2);
vector<ModInt<M>> cs(asLen + bsLen - 1);
for (int i = 0; i < asLen + bsLen - 1; ++i) {
cs[i] = garner<ModInt<M>>(cs0[i], cs1[i], cs2[i]);
}
return cs;
}
template <unsigned M> vector<ModInt<M>> square(const vector<ModInt<M>> &as) {
static constexpr unsigned M0 = decltype(FFT0)::M;
static constexpr unsigned M1 = decltype(FFT1)::M;
static constexpr unsigned M2 = decltype(FFT2)::M;
if (as.empty()) return {};
const int asLen = as.size();
vector<ModInt<M0>> as0(asLen);
for (int i = 0; i < asLen; ++i) as0[i] = as[i].x;
const vector<ModInt<M0>> cs0 = FFT0.square(as0);
vector<ModInt<M1>> as1(asLen);
for (int i = 0; i < asLen; ++i) as1[i] = as[i].x;
const vector<ModInt<M1>> cs1 = FFT1.square(as1);
vector<ModInt<M2>> as2(asLen);
for (int i = 0; i < asLen; ++i) as2[i] = as[i].x;
const vector<ModInt<M2>> cs2 = FFT2.square(as2);
vector<ModInt<M>> cs(asLen + asLen - 1);
for (int i = 0; i < asLen + asLen - 1; ++i) {
cs[i] = garner<ModInt<M>>(cs0[i], cs1[i], cs2[i]);
}
return cs;
}
template <unsigned M> vector<ModInt<M>> middle(const vector<ModInt<M>> &as, const vector<ModInt<M>> &bs) {
static constexpr unsigned M0 = decltype(FFT0)::M;
static constexpr unsigned M1 = decltype(FFT1)::M;
static constexpr unsigned M2 = decltype(FFT2)::M;
const int asLen = as.size(), bsLen = bs.size();
assert(asLen >= bsLen); assert(bsLen >= 1);
vector<ModInt<M0>> as0(asLen), bs0(bsLen);
for (int i = 0; i < asLen; ++i) as0[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs0[i] = bs[i].x;
const vector<ModInt<M0>> cs0 = FFT0.middle(as0, bs0);
vector<ModInt<M1>> as1(asLen), bs1(bsLen);
for (int i = 0; i < asLen; ++i) as1[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs1[i] = bs[i].x;
const vector<ModInt<M1>> cs1 = FFT1.middle(as1, bs1);
vector<ModInt<M2>> as2(asLen), bs2(bsLen);
for (int i = 0; i < asLen; ++i) as2[i] = as[i].x;
for (int i = 0; i < bsLen; ++i) bs2[i] = bs[i].x;
const vector<ModInt<M2>> cs2 = FFT2.middle(as2, bs2);
vector<ModInt<M>> cs(asLen - bsLen + 1);
for (int i = 0; i < asLen - bsLen + 1; ++i) {
cs[i] = garner<ModInt<M>>(cs0[i], cs1[i], cs2[i]);
}
return cs;
}
constexpr unsigned MO = 1'000'000'007;
using Mint = ModInt<MO>;
// Returns f: poly s.t. deg(f) < n := |ys| && f(q^i) = ys[i].
// Assumes ord(q) >= n.
// Requires convolve and middle.
// f(x) = \sum[0<=i<n] ys[i] \prod[0<=j<n, j!=i] (x-q^j)/(q^i-q^j)
// = (\prod[0<=i<n] (x-q^i)) (\sum[0<=i<n] ys[i]zs[i]/(x-q^i))
// = (\sum[0<=k<=n] (-1)^k q^binom(k,2) binom(n,k)_q x^(n-k))
// * (\sum[0<=i<n] ys[i]zs[i] \sum[k>=0] -(q^i)^-(k+1) x^k) in K[[x]]
// zs[i] := \prod[0<=j<n, j!=i] 1/(q^i-q^j)
// = (-1)^i q^-(binom(n-1,2)-binom(n-1-i)/2) (q;q)_i^-1 (q;q)_(n-1-i)^-1
vector<Mint> interpolateQ(Mint q, vector<Mint> ys) {
const int n = ys.size();
if (n <= 1) return ys;
assert(q);
vector<Mint> qs(2 * n), q2s(2 * n), invQ2s(2 * n), pochs(n + 1), invPochs(n);
qs[0] = q2s[0] = 1;
for (int i = 1; i <= 2 * n - 1; ++i) {
qs[i] = qs[i - 1] * q;
q2s[i] = q2s[i - 1] * qs[i - 1];
}
invQ2s[2 * n - 1] = q2s[2 * n - 1].inv();
for (int i = 2 * n - 1; i >= 1; --i) invQ2s[i - 1] = qs[i - 1] * invQ2s[i];
pochs[0] = 1;
for (int i = 1; i <= n; ++i) pochs[i] = pochs[i - 1] * (1 - qs[i]);
assert(pochs[n - 1]);
invPochs[n - 1] = pochs[n - 1].inv();
for (int i = n - 1; i >= 1; --i) invPochs[i - 1] = (1 - qs[i]) * invPochs[i];
vector<Mint> fs(n);
for (int k = 1; k < n; ++k) fs[n - k] = (k&1?-1:+1) * q2s[k] * pochs[n] * invPochs[k] * invPochs[n - k];
fs[0] = (n&1?-1:+1) * q2s[n];
for (int i = 0; i < n; ++i) ys[i] *= (i&1?-1:+1) * invQ2s[n - 1] * q2s[n - 1 - i] * invPochs[i] * invPochs[n - 1 - i] * -q2s[i];
auto gs = middle(invQ2s, ys);
for (int k = 0; k <= n; ++k) gs[k] *= q2s[k];
gs.erase(gs.begin());
fs = convolve(fs, gs);
fs.resize(n);
return fs;
}
#define rep(i) for (int i = 0; i < N; ++i)
int N, M;
Mint A[2][6][6];
// [m, M), [M, M+m)
Mint L[500'010][6][6];
Mint R[500'010][6][6];
int main() {
for (; ~scanf("%d%d", &N, &M); ) {
for (int d = 2; --d >= 0; ) rep(i) rep(j) {
scanf("%u", &A[d][i][j].x);
}
vector<Mint> two(2*M);
two[0] = 1;
for (int m = 1; m < 2*M; ++m) two[m] = two[m - 1] * 2;
memset(L, 0, sizeof(L));
memset(R, 0, sizeof(R));
rep(i) L[M][i][i] = R[0][i][i] = 1;
{
Mint a[6][6];
for (int m = M; --m >= 0; ) {
rep(i) rep(j) a[i][j] = A[0][i][j] + A[1][i][j] * two[m];
rep(i) rep(k) rep(j) L[m][i][j] += a[i][k] * L[m + 1][k][j];
}
for (int m = 0; m < M; ++m) {
rep(i) rep(j) a[i][j] = A[0][i][j] + A[1][i][j] * two[M + m];
rep(i) rep(k) rep(j) R[m + 1][i][j] += R[m][i][k] * a[k][j];
}
}
vector<Mint> ys(M + 1, 0);
for (int m = 0; m <= M; ++m) {
rep(k) ys[m] += L[m][0][k] * R[m][k][0];
}
// cerr<<"ys = "<<ys<<endl;
const auto ans = interpolateQ(2, ys);
for (int h = 0; h <= M; ++h) {
printf("%u\n", ans[h].x);
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 7ms
memory: 144408kb
input:
2 2 1 2 3 4 2 0 1 2
output:
4 8 14
result:
ok 3 number(s): "4 8 14"
Test #2:
score: 0
Accepted
time: 4ms
memory: 144388kb
input:
4 10 520471651 866160932 848899741 650346545 756377215 402412491 920748640 255249004 371442152 93295238 350011159 679848583 528399020 957465601 22001245 407745834 363922864 418156995 324388560 611306817 671914474 323815171 638034305 796072406 765823638 254662378 175686978 123364350 786531344 3967179...
output:
890467395 623743197 432365684 555543126 145580696 550546744 959254454 836036617 945090197 106843161 866547396
result:
ok 11 numbers
Test #3:
score: 0
Accepted
time: 3ms
memory: 144416kb
input:
6 23 101670804 457970042 521121852 851881468 298366530 271962368 881900040 161849089 409608300 527884448 898980182 538728808 624037110 955334452 644656371 684645088 612630196 365375437 135489465 838789241 374389562 238291227 977400760 496900790 921432977 606711088 740916866 405856539 822796504 19906...
output:
18827363 93291123 549166310 727345493 212460686 835043567 382235992 234331494 126083178 340949995 361327462 549134620 481914498 34075195 89718312 945811332 898724999 944812555 123616792 779724718 995912550 188150326 361531843 801483934
result:
ok 24 numbers
Test #4:
score: 0
Accepted
time: 3ms
memory: 144336kb
input:
1 1 850150743 201109093
output:
201109093 850150743
result:
ok 2 number(s): "201109093 850150743"
Test #5:
score: 0
Accepted
time: 3ms
memory: 144508kb
input:
2 1 838417478 568611358 348881562 259739663 684020320 849564252 7622864 342206654
output:
684020320 838417478
result:
ok 2 number(s): "684020320 838417478"
Test #6:
score: 0
Accepted
time: 7ms
memory: 144352kb
input:
3 1 662626648 989629820 447555531 504352706 537983436 981463385 633227491 799236931 264904138 510263941 30128899 644015027 642994715 674480107 494744466 113567281 686079810 29940910
output:
510263941 662626648
result:
ok 2 number(s): "510263941 662626648"
Test #7:
score: 0
Accepted
time: 3ms
memory: 144668kb
input:
4 1 698286849 108948691 370848972 861145616 308345962 492551526 837788523 735191312 813226172 232618279 121444192 64535733 172831199 302337428 438860400 394173985 968865126 421436111 675658174 967155308 675554219 293733850 793671127 135966551 267239055 24766491 712336945 25719396 621692331 201339445...
output:
968865126 698286849
result:
ok 2 number(s): "968865126 698286849"
Test #8:
score: 0
Accepted
time: 3ms
memory: 144692kb
input:
5 1 346030494 348813388 950014436 351718810 389309705 819298156 278971731 721089919 34315191 136072724 977938439 445268765 725373786 92574089 40828378 81532232 217673244 195836050 397811725 905085770 76139672 852963918 237501084 582369241 723129091 510859036 368205749 459903015 796344358 178557942 9...
output:
510859036 346030494
result:
ok 2 number(s): "510859036 346030494"
Test #9:
score: 0
Accepted
time: 4ms
memory: 144708kb
input:
6 1 269535050 794196606 377757516 516758696 739552010 15300040 523493270 110895534 879184568 693817999 162914386 60443980 122215232 3304271 774066505 279824412 19713957 620002064 784042807 447807660 446909111 377390001 200803795 138848111 379227514 56112455 336718555 609352443 37005361 252594923 861...
output:
552563198 269535050
result:
ok 2 number(s): "552563198 269535050"
Test #10:
score: 0
Accepted
time: 482ms
memory: 208920kb
input:
1 500000 706182264 736952709
output:
892233922 468115873 308143942 193363163 378936361 937405642 111313747 969580402 589989221 484787638 967509440 18352732 434816380 65365234 882512561 767325052 712563415 746546040 946131121 227820023 169312342 907085632 724543244 561505515 232284120 206818537 152379044 545917327 806526105 402291935 61...
result:
ok 500001 numbers
Test #11:
score: 0
Accepted
time: 496ms
memory: 206420kb
input:
2 500000 9127286 930973671 308653261 288625105 830331388 719198622 459549621 225552114
output:
1462633 214100825 791502063 293289955 192705128 122334123 600156406 227749427 182750092 921068323 462422846 477854277 154766642 816116803 280191002 781126552 131549399 118650763 142492481 211202323 924321962 412948387 627761451 27372777 229268499 78319390 31336361 340023411 877921612 622255208 98357...
result:
ok 500001 numbers
Test #12:
score: 0
Accepted
time: 555ms
memory: 207364kb
input:
3 500000 56578005 645024640 431691230 161018027 400592972 404855462 103822717 117958238 396708288 613222707 660031402 321011642 763754233 907644315 127924143 389957560 970378906 93724403
output:
348089563 39592003 181211922 759146777 72259612 523655439 681601862 633014937 106326635 557992530 820150122 405568824 64003796 804358627 241178119 201229615 713392673 369068526 866395847 405554585 87185993 486838277 827391750 888520772 426518125 803184967 428085295 74377725 633201631 639800164 42664...
result:
ok 500001 numbers
Test #13:
score: 0
Accepted
time: 589ms
memory: 208964kb
input:
4 500000 556298461 638193619 513087994 249347436 593518518 204200114 312456495 858802953 663647987 975405217 819079551 899844790 37809935 890176663 754356618 801985468 288658683 320943414 690796464 919583169 278555113 161442134 12366556 612551563 117524026 615099968 878729097 554909666 919036171 464...
output:
443898529 8558921 125159632 884389507 860907918 295699151 691502818 206487427 633314932 505738165 532065960 779855592 913351742 262744857 711171183 582483344 725366455 6147918 786541235 22961493 93905112 945128598 721108023 876061523 854800308 300830527 387609878 514109547 283444727 460259655 431240...
result:
ok 500001 numbers
Test #14:
score: 0
Accepted
time: 699ms
memory: 208456kb
input:
5 500000 766847766 287312498 244182009 125792652 730747507 214389762 844928898 484381301 959778760 178213282 564701639 136477159 259093123 555040775 975093083 941752530 6568303 871810927 245335011 176936040 572923411 880854159 837338121 681477662 987829678 257339995 81247713 804471529 195954794 2460...
output:
750938212 962767630 81861498 523422670 604672320 870378137 639625252 649306504 925346908 898435708 339690883 184622949 295355382 219119251 444143321 719020631 776690438 376139524 30708522 40577397 320520270 755473416 372974280 632453883 686539783 356535755 536667758 503328362 71399172 789207095 4662...
result:
ok 500001 numbers
Test #15:
score: 0
Accepted
time: 813ms
memory: 208996kb
input:
6 500000 305611446 704447928 578988388 809440962 729555107 574817609 504376836 943544749 63621978 921478266 706913128 135673671 713514013 481340046 311263276 131724043 904100870 702794548 707918139 920766196 550304293 825935048 156074334 669618807 395245548 725021871 620389625 855337996 410182560 51...
output:
494898338 320275476 396834976 131339557 482654987 72119885 421633888 830947703 291005717 668992696 5968531 430532071 835903593 932145897 40867819 828601757 297712145 81399820 549872782 84372839 154323647 503684167 45737273 375203411 702703977 476487747 408837084 767238319 973325935 729664935 2171010...
result:
ok 500001 numbers
Test #16:
score: 0
Accepted
time: 428ms
memory: 186176kb
input:
2 287370 502541782 166554826 42035120 731584023 315062065 627211583 621602584 840445263
output:
844864234 440361356 734672803 131476579 395575595 941831505 691614790 302852383 474208074 781961339 521039753 772370429 635143477 866502611 137825474 363878002 344397110 653060252 115422788 451345054 365918444 643425773 892672895 253079401 834302186 93473264 83199974 149320133 97813422 195615002 817...
result:
ok 287371 numbers
Test #17:
score: 0
Accepted
time: 20ms
memory: 146160kb
input:
2 16195 245257877 496149507 105779654 795943692 750002684 639852324 473663922 147666028
output:
583308345 578534903 442704627 755586030 75549815 808385883 400565388 715034957 85791029 396972964 280313468 85979128 143467302 488900111 693184723 534323613 136627774 182638473 655145413 967976676 54141306 253543915 37770128 844832914 775080804 149196375 728515683 674586973 481296626 286302667 68622...
result:
ok 16196 numbers
Test #18:
score: 0
Accepted
time: 443ms
memory: 184768kb
input:
3 272838 90201741 970956431 136519070 963491300 297855703 276427567 910998511 667321493 439003200 646721534 555024174 696088480 741924730 165157611 181362732 884158437 537772049 649907546
output:
351594308 289722161 383709713 489173141 185236640 773420020 789444828 794151163 699762110 2029927 665894064 252839122 536331848 948096024 135951331 446012869 611039178 979860382 835407850 665054994 158091644 217626919 107568761 153572115 396640881 986289801 284685382 31839082 671763164 190452404 476...
result:
ok 272839 numbers
Test #19:
score: 0
Accepted
time: 327ms
memory: 174756kb
input:
5 229983 961898083 364203171 834317853 385699091 265242370 826220048 651093637 427842173 968168261 520386114 502282397 102038425 194125248 635400149 807886342 680400239 136413404 261304662 143404522 723157723 428158667 918773802 350134863 611466467 133934957 481968646 138725241 461635071 915980316 6...
output:
854937854 878245553 762004791 768000506 703178539 64258060 977587301 340697822 918293513 300441868 32171407 243104114 977700909 727968210 948158716 356547939 998056509 607606174 228251094 931776099 69720169 197205608 859659360 275523027 668080076 288881564 736719809 448338032 68326056 228609374 4437...
result:
ok 229984 numbers
Test #20:
score: 0
Accepted
time: 393ms
memory: 173752kb
input:
6 235159 910406808 386253987 521832246 111360980 112009306 270997749 920110786 272246658 435679475 619458685 241406542 723150614 308677704 699438606 139175767 517432789 257864599 308332553 267194866 355823791 662257072 146875106 305591172 363702810 503849353 668064153 35979534 191398114 971349018 29...
output:
952330760 671275817 642041926 884122360 616250387 103430064 750940986 237686223 745756340 988531041 191086539 829751359 808594887 656224765 39383670 144254027 247106893 476661385 484089639 539610322 837037069 3202049 150420633 980126159 718359811 450885790 189542554 240670352 329309878 478439781 138...
result:
ok 235160 numbers
Test #21:
score: 0
Accepted
time: 818ms
memory: 207372kb
input:
6 500000 403540836 557481829 125956545 606526099 853032214 311601729 451394496 601328051 462518778 736049932 211675387 321576456 592915123 800358584 862906706 915956357 241985386 788105310 6827280 929478475 948697853 772495026 711522446 295078409 843087543 675240698 393087117 955494053 105853311 960...
output:
758374487 976822870 556083126 225822635 494681953 687682287 141451119 444325979 31683450 119024361 374438735 178013665 842545153 881714332 226639265 387728272 328961585 538507451 642098191 121595063 344647711 644216587 125371311 118587186 858669048 634347146 453150321 744529645 521364195 584625262 8...
result:
ok 500001 numbers
Test #22:
score: 0
Accepted
time: 841ms
memory: 207680kb
input:
6 500000 827230290 450361755 423910836 392438536 792203018 157520529 673944378 80681751 956016203 291685370 724597715 764998400 343522614 74796941 834270698 666906829 985938116 678112166 335476139 129169781 924292376 759019664 790638071 699001887 315440702 548504297 638181738 313404027 677854328 296...
output:
790526202 749874384 651469120 7572034 673118221 962386472 43201004 540690558 192136037 907324096 969235617 597468872 670353636 694547930 515861862 426495921 436076040 493792150 682361695 35257744 469902148 815345339 835092861 293841059 437722489 197287084 419717039 40932830 128808390 387856010 32379...
result:
ok 500001 numbers
Test #23:
score: 0
Accepted
time: 831ms
memory: 208756kb
input:
6 500000 703002354 979288110 580610968 162864014 287592003 646855250 60240619 999294199 741749632 443510995 173571034 925592618 63608664 697718272 216551463 669415606 201271812 488608662 68324509 500021844 763638203 31278332 635182635 373354014 13713570 703237567 637554111 502295273 318453760 723112...
output:
856457067 449456673 14394553 785949213 946755988 742556104 213262174 521045098 411183546 134100596 472465483 677084677 4119344 410562207 127124515 777082598 735219472 429905518 852741672 837106674 558486349 982537542 993253464 695871113 149760231 441112774 888529985 649166079 234333380 798264353 571...
result:
ok 500001 numbers
Test #24:
score: 0
Accepted
time: 817ms
memory: 208072kb
input:
6 500000 676261813 375106150 470825684 763790423 442147821 885025733 82030392 305373 837445120 332317805 734133014 206289266 715297083 384634881 632684303 259819207 947166101 798134522 635915100 872724807 572539045 863265738 507747837 691633507 747364841 329039787 401317487 770619008 319809205 95549...
output:
456946706 417894922 528988129 906275433 464662799 281196160 13209032 572946639 288013197 389123662 167498408 538526092 439657429 672448265 440593449 191184245 90430332 377704794 599922131 634440544 465023824 185868651 824940825 568294137 940901287 715545623 352514375 468722078 660337174 648728834 54...
result:
ok 500001 numbers
Test #25:
score: 0
Accepted
time: 853ms
memory: 207980kb
input:
6 500000 713477597 943046561 280502446 678021563 960195165 734289580 690201977 591724975 124893971 565917007 162080892 10562431 355385342 809437493 980799736 216696983 967678195 873781440 77758877 149654942 547276363 401389646 909661901 751503920 101330416 105778044 768876018 16405510 849508157 1385...
output:
823388933 398682977 865679397 425450075 342159319 746633243 625062490 72635234 661797573 606216835 118730122 970532447 180582445 184285762 548132181 476978819 788417975 436244127 515027122 587185604 525376948 255840734 825810539 994825218 410154584 520887137 129018122 544109015 490973475 143024238 6...
result:
ok 500001 numbers
Test #26:
score: 0
Accepted
time: 850ms
memory: 207932kb
input:
6 500000 271963524 118367822 838144038 267880976 76106099 288710911 124989183 454208721 655367392 316140284 495218913 571405245 61100137 412836099 16669242 987092990 760726661 489115819 2177620 92045744 824601971 299619085 922568010 768621133 27512205 688662136 481421052 598989294 883485752 51507568...
output:
352337042 215481794 126297694 145676881 819548703 896084736 122471658 986624001 369947037 360625895 542767887 903688076 179751713 948413672 686354679 414305434 240926287 585237876 693913413 956876668 713246974 607440900 483313177 648839228 757289855 224075907 778328161 342016004 984041447 20881612 9...
result:
ok 500001 numbers
Test #27:
score: 0
Accepted
time: 846ms
memory: 208988kb
input:
6 500000 996461141 371192464 191756316 549199091 504424437 669832933 772835760 73254458 679562681 18219804 203834533 610595972 535911021 510122832 879727003 146838229 451412803 909005396 455042620 712064179 810050352 543694310 327366991 203930929 83239897 146421377 961582407 427337353 721797675 1184...
output:
968032079 857176206 230669057 250531994 767393171 643794351 443623208 998229141 567603091 900073194 285820409 650964362 389889543 103937524 675362139 392890870 688234464 815435314 470361598 713100705 621188702 837456472 271385051 181362435 780632940 233761119 297577911 932842313 719560728 829683030 ...
result:
ok 500001 numbers
Test #28:
score: 0
Accepted
time: 857ms
memory: 210040kb
input:
6 500000 228566567 743797312 499130403 813574845 724056272 497694585 304093433 960998797 282288898 638149269 841447771 573110238 799621674 288820395 891344948 469923346 630581186 346203560 36299776 204996290 808893048 420247209 21135083 882546629 291652177 166722964 720455243 104733894 399724548 841...
output:
60067114 531442267 653518263 783599382 608818909 738992755 194923456 570104422 823012834 283680738 959555777 276383622 422648426 852050002 146412908 340126332 519742082 276140454 663679915 696911201 845509209 487969582 85127389 186863028 143087181 937223247 896879725 225000141 210203068 555033730 29...
result:
ok 500001 numbers
Test #29:
score: 0
Accepted
time: 821ms
memory: 208636kb
input:
6 500000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30419035 151621662 315934471 257353696 311512017 17346736 562566186 753148991 906484722 822962637 664619958 131461042 778810357 552858440 803819141 944997532 858225742 626139121 850353153 381788492 38064614 875599322 56...
output:
703355896 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500001 numbers
Test #30:
score: 0
Accepted
time: 817ms
memory: 209724kb
input:
6 500000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 281233456 79204751 828147547 834314625 331437691 974450949 886816224 110033167 344034508 88273215 770474654 41135174 942893714 932828388 342360595 945846658 97100895 960920771 44647740 922781780 66486229 742562766 15120...
output:
443834315 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500001 numbers
Test #31:
score: 0
Accepted
time: 853ms
memory: 207764kb
input:
6 500000 945378686 821821675 815832851 19649065 603104043 246853667 739090348 846081394 527037154 617153629 155044399 933566988 944859140 679755045 30047678 352675504 362338411 631801011 446716092 354536735 505534946 6804873 552875623 18863595 286611635 275946030 334007320 138782385 348312456 470346...
output:
566949298 161708678 928903854 262810102 607059033 239532348 584839418 364592284 182411032 23231742 780422914 360960835 757371346 172608062 695563118 982106316 747082811 402256416 914127459 469438083 430866255 586047786 221997956 132487885 97706016 390013027 403010702 284983498 614292288 144977975 92...
result:
ok 500001 numbers
Test #32:
score: 0
Accepted
time: 875ms
memory: 207676kb
input:
6 500000 509295630 935586694 530319530 250957692 188063542 761780640 3552980 659151374 562758171 758615415 438884472 798752089 706090829 273938084 946188846 479545493 214990466 203542791 2247069 185533263 111312603 372678890 478064561 21019879 20063228 47748820 429283988 504691026 855418558 69044627...
output:
895322037 370596189 459441320 363920887 171711377 537604536 477421660 748537103 23216289 261686647 819355379 160260633 250806423 412864916 54048611 139730127 834333063 370037922 513430159 150374823 451847057 692413703 968461344 822462905 130459021 321200592 212848918 190208767 276312073 855191106 24...
result:
ok 500001 numbers
Test #33:
score: 0
Accepted
time: 826ms
memory: 208736kb
input:
6 500000 246174589 329079780 33023023 967175038 669095031 182076904 2345359 763759873 372390803 251784833 131178624 327178325 254246938 709579662 928704249 821183353 824973232 96951771 602085754 312331217 900739254 38680854 495326767 236623776 869847618 533997176 556393025 80047120 381821517 5931073...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500001 numbers
Test #34:
score: 0
Accepted
time: 822ms
memory: 208728kb
input:
6 500000 18964680 911813810 411416484 853261878 950339106 439746786 259269554 299091121 639011650 303091306 224377661 134072698 649497986 453281404 102327698 760977669 412831577 313045154 14976531 454978221 703443606 879226113 318322990 672745059 324821964 379335080 679500247 42624986 212351830 9531...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500001 numbers
Test #35:
score: 0
Accepted
time: 834ms
memory: 207276kb
input:
6 500000 152736944 806868046 745768543 343613292 525080264 193184824 935821334 178938313 939129194 54123811 199575375 967629641 57725959 611334695 66726600 487510869 945070381 262268520 236846979 326244741 669628002 549794317 844703004 982756541 892463913 541461722 385224298 875331007 351527682 3982...
output:
859826056 945889346 690639392 296778992 917570984 135409540 253161734 93830458 319242125 774343139 841834945 814371873 642820430 913068066 942306218 130120741 975523257 916380497 595553261 911256985 922056591 301878043 285613996 851187482 241732322 552983000 789450739 219939261 160147659 169952796 8...
result:
ok 500001 numbers
Test #36:
score: 0
Accepted
time: 821ms
memory: 208976kb
input:
6 500000 302132350 213331521 238941587 96841222 891563954 448244742 276753521 169527091 604769094 314078413 201099771 818349449 440180534 33087829 982636060 961824609 203067477 603579259 717607811 566334731 740317219 307300173 95844979 253835206 232050879 248837207 962160703 483081814 594128817 7978...
output:
66405301 269139361 973021201 515857628 923780976 676101958 228605861 944140774 401443555 149068825 370510868 644916253 291381763 876090296 767382283 153040801 458050179 647887024 184750342 745181314 899303567 323249526 132705215 123146292 414013922 17048746 106269413 792849592 678138643 747092269 24...
result:
ok 500001 numbers
Test #37:
score: 0
Accepted
time: 824ms
memory: 208908kb
input:
6 500000 780148754 498710122 192363019 8646581 367949097 441328549 414708 527554818 727597889 965851211 232432410 218777783 506212023 649019777 190774451 153121389 825784220 842325205 0 0 0 0 0 0 257900311 908544137 218855372 736500119 261775531 541115444 428715540 614461901 12328490 939057944 88955...
output:
247565737 326021589 177909182 67486965 841896580 704189514 381150140 917212959 62802992 333711312 972750128 614115380 373071335 881453727 844436357 42183929 660292229 940427032 601177364 701923901 973733573 208394492 449887492 979697916 969958108 376270228 597499689 510974106 276035423 511502367 286...
result:
ok 500001 numbers
Test #38:
score: 0
Accepted
time: 843ms
memory: 207512kb
input:
6 500000 137422822 46723812 381843708 966079926 855219945 573574647 15009149 702528035 523601442 855200514 247006233 347885186 0 0 0 0 0 0 371295021 841698395 950150379 489029164 693250682 291693978 869280775 670743287 965564151 776515704 641331115 631642318 83494656 987870304 940132774 700608218 46...
output:
26524342 627658892 517303704 310703409 120329967 779265702 807280410 872416517 579282014 522713508 264573027 116914150 130253615 11186917 454937657 499121217 324104940 929684982 16169922 211549779 355206053 87451893 20578259 41601030 928774215 305133390 946956489 477662656 35838554 137168557 4133144...
result:
ok 500001 numbers
Extra Test:
score: 0
Extra Test Passed