QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#67514 | #2988. 染色 | alpha1022 | 100 ✓ | 445ms | 206000kb | C++23 | 16.3kb | 2022-12-10 16:50:05 | 2022-12-10 16:50:07 |
Judging History
answer
#include <cstdio>
#include <chrono>
#include <random>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <initializer_list>
using ll = long long;
using namespace std;
const int mod = 1004535809, G = 3;
inline int norm(int x) {
return x >= mod ? x - mod : x;
}
inline int reduce(int x) {
return x < 0 ? x + mod : x;
}
inline int neg(int x) {
return x ? mod - x : 0;
}
inline void add(int &x, int y) {
if ((x += y - mod) < 0)
x += mod;
}
inline void sub(int &x, int y) {
if ((x -= y) < 0)
x += mod;
}
inline void fam(int &x, int y, int z) {
x = (x + (ll)y * z) % mod;
}
inline int mpow(int a, int b) {
int ret = 1;
for (; b; b >>= 1)
(b & 1) && (ret = (ll)ret * a % mod),
a = (ll)a * a % mod;
return ret;
}
const int BRUTE_N2_LIMIT = 50;
struct NumberTheory {
typedef pair<int, int> P2_Field;
mt19937 rng;
NumberTheory(): rng(chrono::steady_clock::now().time_since_epoch().count()) {}
void exGcd(int a, int b, int &x, int &y) {
if (!b) {
x = 1, y = 0;
return;
}
exGcd(b, a % b, y, x), y -= a / b * x;
}
int inv(int a, int p = mod) {
int x, y;
exGcd(a, p, x, y);
if (x < 0)
x += p;
return x;
}
template<class Integer>
bool quadRes(Integer a, Integer b) {
if (a <= 1)
return 1;
while (a % 4 == 0)
a /= 4;
if (a % 2 == 0)
return (b % 8 == 1 || b % 8 == 7) == quadRes(a / 2, b);
return ((a - 1) % 4 == 0 || (b - 1) % 4 == 0) == quadRes(b % a, a);
}
int sqrt(int x, int p = mod) {
if (p == 2 || x <= 1)
return x;
int w, v, k = (p + 1) / 2;
do
w = rng() % p;
while (quadRes(v = ((ll)w * w - x + p) % p, p));
P2_Field res(1, 0), a(w, 1);
for (; k; k >>= 1) {
if (k & 1)
res = P2_Field(((ll)res.first * a.first + (ll)res.second * a.second % p * v) % p, ((ll)res.first * a.second + (ll)res.second * a.first) % p);
a = P2_Field(((ll)a.first * a.first + (ll)a.second * a.second % p * v) % p, 2LL * a.first * a.second % p);
}
return min(res.first, p - res.first);
}
} nt;
namespace Simple {
int n = 1;
vector<int> fac({1, 1}), ifac({1, 1}), inv({0, 1});
void build(int m) {
n = m;
fac.resize(n + 1), ifac.resize(n + 1), inv.resize(n + 1);
inv[1] = 1;
for (int i = 2; i <= n; ++i)
inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
fac[0] = ifac[0] = 1;
for (int i = 1; i <= n; ++i)
fac[i] = (ll)fac[i - 1] * i % mod,
ifac[i] = (ll)ifac[i - 1] * inv[i] % mod;
}
void check(int k) {
int m = n;
if (k > m) {
while (k > m)
m <<= 1;
build(m);
}
}
inline int gfac(int k) {
check(k);
return fac[k];
}
inline int gifac(int k) {
check(k);
return ifac[k];
}
inline int ginv(int k) {
check(k);
return inv[k];
}
}
struct SimpleSequence {
function<int(int)> func;
inline SimpleSequence(function<int(int)> func): func(func) {}
inline int operator[](int k) const {
return func(k);
}
} gfac(Simple::gfac), gifac(Simple::gifac), ginv(Simple::ginv);
inline int binom(int n, int m) {
if (m > n || m < 0)
return 0;
return (ll)gfac[n] * gifac[m] % mod * gifac[n - m] % mod;
}
namespace NTT {
int L = -1;
vector<int> root;
void init(int l) {
L = l;
root.resize((1 << L) + 1);
int n = 1 << L, *w = root.data();
w[0] = 1, w[1 << L] = mpow(4172, 1 << (19 - L));
for (int i = L; i; --i)
w[1 << (i - 1)] = (ll)w[1 << i] * w[1 << i] % mod;
for (int i = 1; i < n; ++i)
w[i] = (ll)w[i & (i - 1)] * w[i & -i] % mod;
}
void DIF(int *a, int l) {
int n = 1 << l;
for (int len = n >> 1; len; len >>= 1)
for (int *j = a, *o = root.data(); j != a + n; j += len << 1, ++o)
for (int *k = j; k != j + len; ++k) {
int r = (ll)*o * k[len] % mod;
k[len] = reduce(*k - r), add(*k, r);
}
}
void DIT(int *a, int l) {
int n = 1 << l;
for (int len = 1; len < n; len <<= 1)
for (int *j = a, *o = root.data(); j != a + n; j += len << 1, ++o)
for (int *k = j; k != j + len; ++k) {
int r = norm(*k + k[len]);
k[len] = (ll)*o * (*k - k[len] + mod) % mod, *k = r;
}
}
void fft(int *a, int lgn, int d = 1) {
if (L < lgn)
init(lgn);
int n = 1 << lgn;
if (d == 1)
DIF(a, lgn);
else {
DIT(a, lgn), reverse(a + 1, a + n);
int nInv = mod - (mod - 1) / n;
for (int i = 0; i < n; ++i)
a[i] = (ll)a[i] * nInv % mod;
}
}
}
struct poly {
vector<int> a;
poly(ll v = 0): a(1) {
if ((v %= mod) < 0)
v += mod;
a[0] = v;
}
poly(const poly &o): a(o.a) {}
poly(const vector<int> &o): a(o) {}
poly(initializer_list<int> o): a(o) {}
int operator[](int k) const { return k < a.size() ? a[k] : 0; }
int &operator[](int k) {
if (k >= a.size())
a.resize(k + 1);
return a[k];
}
int deg() const { return (int)a.size() - 1; }
void redeg(int d) { a.resize(d + 1); }
int size() const {return a.size(); }
void resize(int s) { a.resize(s); }
poly slice(int d) const {
if (d < a.size())
return vector<int>(a.begin(), a.begin() + d + 1);
vector<int> ret = a;
ret.resize(d + 1);
return ret;
}
poly shift(int k) const {
if (size() + k <= 0)
return 0;
vector<int> ret(size() + k);
for (int i = max(0, k); i < ret.size(); ++i)
ret[i] = a[i - k];
return ret;
}
int *base() { return a.data(); }
const int *base() const { return a.data(); }
poly println(FILE *fp = stdout) const {
for (int i = 0; i < a.size(); ++i)
fprintf(fp, "%d%c", a[i], " \n"[i == a.size() - 1]);
return *this;
}
poly &operator+=(const poly &o) {
if (o.size() > a.size())
a.resize(o.size());
for (int i = 0; i < o.size(); ++i)
add(a[i], o[i]);
return *this;
}
poly operator+(const poly &o) const { poly ret(a); ret += o; return ret; }
poly operator-() const {
poly ret = a;
for (int i = 0; i < a.size(); ++i)
ret[i] = neg(ret[i]);
return ret;
}
poly &operator-=(const poly &o) { return operator+=(-o); }
poly operator-(const poly &o) { return operator+(-o); }
poly operator*(const poly &) const;
poly operator/(const poly &) const;
poly operator%(const poly &) const;
poly &operator*=(const poly &o) { *this = operator*(o); return *this; }
poly &operator/=(const poly &o) { *this = operator/(o); return *this; }
poly &operator%=(const poly &o) { *this = operator%(o); return *this; }
poly deriv() const;
poly integ() const;
poly inv() const;
poly sqrt() const;
poly ln() const;
poly exp() const;
pair<poly, poly> sqrti() const;
pair<poly, poly> expi() const;
poly quo(const poly &) const;
pair<poly, poly> iquo() const;
pair<poly, poly> div(const poly &) const;
poly taylor(int k) const;
poly pow(int k) const;
poly exp(int k) const;
};
poly zeroes(int d) { return vector<int>(d + 1); }
namespace NTT { void fft(poly &a, int lgn, int d = 1) { fft(a.base(), lgn, d); } }
using NTT::fft;
struct Newton {
void inv(const poly &f, const poly &dftf, poly &g, const poly &dftg, int t) {
int n = 1 << t;
poly prod = dftf;
for (int i = 0; i < (n << 1); ++i)
prod[i] = (ll)prod[i] * dftg[i] % mod;
fft(prod, t + 1, -1);
memset(prod.base(), 0, sizeof(int) << t);
fft(prod, t + 1);
for (int i = 0; i < (n << 1); ++i)
prod[i] = (ll)prod[i] * dftg[i] % mod;
fft(prod, t + 1, -1);
for (int i = 0; i < n; ++i)
prod[i] = 0;
g -= prod;
}
void inv(const poly &f, const poly &dftf, poly &g, int t) {
poly dftg(g);
dftg.resize(2 << t);
fft(dftg, t + 1);
inv(f, dftf, g, dftg, t);
}
void inv(const poly &f, poly &g, int t) {
poly dftf(f), dftg(g);
dftf.resize(2 << t), dftg.resize(2 << t);
fft(dftf, t + 1), fft(dftg, t + 1);
inv(f, dftf, g, dftg, t);
}
void sqrt(const poly &f, poly &g, poly &dftg, poly &h, int t) {
for (int i = 0; i < (1 << t); ++i)
dftg[i] = (ll)dftg[i] * dftg[i] % mod;
fft(dftg, t, -1);
dftg -= f;
for (int i = 0; i < (1 << t); ++i)
add(dftg[i | (1 << t)], dftg[i]),
dftg[i] = 0;
fft(dftg, t + 1);
poly tmp = h;
tmp.resize(2 << t);
fft(tmp, t + 1);
for (int i = 0; i < (2 << t); ++i)
tmp[i] = (ll)tmp[i] * dftg[i] % mod;
fft(tmp, t + 1, -1);
memset(tmp.base(), 0, sizeof(int) << t);
g -= tmp * ginv[2];
}
void exp(const poly &f, poly &g, poly &dftg, poly &h, int t) {
poly dfth = h;
fft(dfth, t);
poly dg = g.deriv().slice((1 << t) - 1);
fft(dg, t);
poly tmp = zeroes((1 << t) - 1);
for (int i = 0; i < (1 << t); ++i)
tmp[i] = (ll)dftg[i] * dfth[i] % mod,
dg[i] = (ll)dg[i] * dfth[i] % mod;
fft(tmp, t, -1), fft(dg, t, -1);
sub(tmp[0], 1);
dg.resize(2 << t);
poly df0 = f.deriv().slice((1 << t) - 1);
df0[(1 << t) - 1] = 0;
for (int i = 0; i < (1 << t); ++i)
dg[i | (1 << t)] = reduce(dg[i] - df0[i]);
memcpy(dg.base(), df0.base(), sizeof(int) * ((1 << t) - 1));
tmp.resize(2 << t), fft(tmp, t + 1);
df0.resize(2 << t), fft(df0, t + 1);
for (int i = 0; i < (2 << t); ++i)
df0[i] = (ll)df0[i] * tmp[i] % mod;
fft(df0, t + 1, -1);
for (int i = 0; i < (1 << t); ++i)
df0[i | (1 << t)] = df0[i],
df0[i] = 0;
dg = (dg - df0).integ().slice((2 << t) - 1) - f;
fft(dg, t + 1);
for (int i = 0; i < (2 << t); ++i)
tmp[i] = (ll)dg[i] * dftg[i] % mod;
fft(tmp, t + 1, -1);
g.resize(2 << t);
for (int i = 1 << t; i < (2 << t); ++i)
g[i] = neg(tmp[i]);
}
} nit;
poly poly::operator*(const poly &o) const {
int n = deg(), m = o.deg();
/*if (n <= 10 || m <= 10 || n + m <= BRUTE_N2_LIMIT) {
poly ret = zeroes(n + m);
for (int i = 0; i <= n; ++i)
for (int j = 0; j <= m; ++j)
fam(ret[i + j], a[i], o[j]);
return ret;
}*/
n += m;
int l = 0;
while ((1 << l) <= n)
++l;
poly ret = a, tmp = o;
ret.resize(1 << l), tmp.resize(1 << l);
fft(ret, l), fft(tmp, l);
for (int i = 0; i < (1 << l); ++i)
ret[i] = (ll)ret[i] * tmp[i] % mod;
fft(ret, l, -1);
return ret.slice(n);
}
poly poly::inv() const {
poly g = nt.inv(a[0]);
for (int t = 0; (1 << t) <= deg(); ++t)
nit.inv(slice((2 << t) - 1), g, t);
g.redeg(deg());
return g;
}
poly poly::taylor(int k) const {
int n = deg();
poly f = zeroes(n), g = zeroes(n);
for (int i = 0, pw = 1; i <= n; ++i)
f[n - i] = (ll)a[i] * gfac[i] % mod,
g[i] = (ll)pw * gifac[i] % mod,
pw = (ll)pw * k % mod;
f *= g;
for (int i = 0; i <= n; ++i)
g[i] = (ll)f[n - i] * gifac[i] % mod;
return g;
}
poly poly::pow(int k) const {
if (k == 0)
return 1;
if (k == 1)
return *this;
int n = deg() * k;
int l = 0;
while ((1 << l) <= n)
++l;
poly ret = a;
ret.resize(1 << l), fft(ret, l);
for (int i = 0; i < (1 << l); ++i)
ret[i] = mpow(ret[i], k);
fft(ret, -1);
return ret.slice(n);
}
poly poly::deriv() const {
if (deg() == 0)
return 0;
vector<int> ret(deg());
for (int i = 0; i < deg(); ++i)
ret[i] = (ll)a[i + 1] * (i + 1) % mod;
return ret;
}
poly poly::integ() const {
vector<int> ret(size() + 1);
for (int i = 0; i <= deg(); ++i)
ret[i + 1] = (ll)a[i] * ginv[i + 1] % mod;
return ret;
}
poly poly::quo(const poly &o) const {
if (o.deg() == 0)
return (ll)a[0] * nt.inv(o[0]) % mod;
poly g = nt.inv(o[0]);
int t = 0, n;
for (n = 1; (n << 1) <= o.deg(); ++t, n <<= 1)
nit.inv(o.slice((n << 1) - 1), g, t);
poly dftg = g;
dftg.resize(n << 1), fft(dftg, t + 1);
poly eps1 = o;
eps1.resize(n << 1), fft(eps1, t + 1);
for (int i = 0; i < (n << 1); ++i)
eps1[i] = (ll)eps1[i] * dftg[i] % mod;;
fft(eps1, t + 1, -1);
for (int i = 0; i < n; ++i)
eps1[i] = eps1[i + n],
eps1[i + n] = 0;
fft(eps1, t + 1);
poly h0 = slice(n - 1);
h0.resize(n << 1), fft(h0, t + 1);
poly h0g0 = zeroes((n << 1) - 1);
for (int i = 0; i < (n << 1); ++i)
h0g0[i] = (ll)h0[i] * dftg[i] % mod;
fft(h0g0, t + 1, -1);
poly h0eps1 = zeroes((n << 1) - 1);
for (int i = 0; i < (n << 1); ++i)
h0eps1[i] = (ll)h0[i] * eps1[i] % mod;
fft(h0eps1, t + 1, -1);
for (int i = 0; i < n; ++i)
h0eps1[i] = reduce(operator[](i + n) - h0eps1[i]);
memset(h0eps1.base() + n, 0, sizeof(int) << t);
fft(h0eps1, t + 1);
for (int i = 0; i < (n << 1); ++i)
h0eps1[i] = (ll)h0eps1[i] * dftg[i] % mod;
fft(h0eps1, t + 1, -1);
for (int i = 0; i < n; ++i)
h0eps1[i + n] = h0eps1[i],
h0eps1[i] = 0;
return (h0g0 + h0eps1).slice(o.deg());
}
poly poly::ln() const {
if (deg() == 0)
return 0;
return deriv().quo(slice(deg() - 1)).integ();
}
pair<poly, poly> poly::sqrti() const {
poly g = nt.sqrt(a[0]), h = nt.inv(a[0]), dftg = g;
for (int t = 0; (1 << t) <= deg(); ++t) {
nit.sqrt(slice((2 << t) - 1), g, dftg, h, t);
dftg = g, fft(dftg, t + 1);
nit.inv(g, dftg, h, t);
}
return make_pair(g.slice(deg()), h.slice(deg()));
}
poly poly::sqrt() const {
poly g = nt.sqrt(a[0]), h = nt.inv(a[0]), dftg = g;
for (int t = 0; (1 << t) <= deg(); ++t) {
nit.sqrt(slice((2 << t) - 1), g, dftg, h, t);
if ((2 << t) <= deg()) {
dftg = g, fft(dftg, t + 1);
nit.inv(g, dftg, h, t);
}
}
return g.slice(deg());
}
pair<poly, poly> poly::expi() const {
poly g = 1, h = 1, dftg = {1, 1};
for (int t = 0; (1 << t) <= deg(); ++t) {
nit.exp(slice((2 << t) - 1), g, dftg, h, t);
dftg = g, dftg.resize(4 << t);
fft(dftg, t + 2);
poly f2n = dftg.slice((2 << t) - 1);
nit.inv(g, f2n, h, t);
}
return make_pair(g.slice(deg()), h.slice(deg()));
}
poly poly::exp() const {
poly g = 1, h = 1, dftg = {1, 1};
for (int t = 0; (1 << t) <= deg(); ++t) {
nit.exp(slice((2 << t) - 1), g, dftg, h, t);
if ((2 << t) <= deg()) {
dftg = g, dftg.resize(4 << t);
fft(dftg, t + 2);
poly f2n = dftg.slice((2 << t) - 1);
nit.inv(g, f2n, h, t);
}
}
return g.slice(deg());
}
poly poly::exp(int k) const {
int lead, lz = 0;
while (lz < deg() && !a[lz])
++lz;
if (lz == deg() && !a[lz])
return *this;
lead = a[lz];
if ((ll)lz * k > deg())
return zeroes(deg());
poly part = poly(vector<int>(a.begin() + lz, a.begin() + deg() - lz * (k - 1) + 1)) * nt.inv(lead);
part = (part.ln() * k).exp() * mpow(lead, k);
vector<int> ret(deg() + 1);
memcpy(ret.data() + lz * k, part.base(), sizeof(int) * (deg() - lz * k + 1));
return ret;
}
poly poly::operator/(const poly &o) const {
int n = deg(), m = o.deg();
if (n < m)
return 0;
poly ta(vector<int>(a.rbegin(), a.rend())), tb(vector<int>(o.a.rbegin(), o.a.rend()));
ta.redeg(n - m), tb.redeg(n - m);
poly q = ta.quo(tb);
return vector<int>(q.a.rbegin(), q.a.rend());
}
pair<poly, poly> poly::div(const poly &o) const {
if (deg() < o.deg())
return make_pair(0, *this);
int n = deg(), m = o.deg();
poly q = operator/(o), r;
int l = 0;
while ((1 << l) < o.deg())
++l;
int t = (1 << l) - 1;
poly tmp = zeroes(t);
r = zeroes(t);
for (int i = 0; i <= m; ++i)
add(r[i & t], o[i]);
for (int i = 0; i <= n - m; ++i)
add(tmp[i & t], q[i]);
fft(r, l), fft(tmp, l);
for (int i = 0; i <= t; ++i)
tmp[i] = (ll)tmp[i] * r[i] % mod;
fft(tmp, l, -1);
memset(r.base(), 0, sizeof(int) << l);
for (int i = 0; i <= n; ++i)
add(r[i & t], a[i]);
for (int i = 0; i < m; ++i)
sub(r[i], tmp[i]);
return make_pair(q, r.slice(m - 1));
}
poly poly::operator%(const poly &o) const {
return div(o).second;
}
int n, m, s;
poly f;
int ans;
int main() {
scanf("%d%d%d", &n, &m, &s), f.redeg(m);
for (int i = 0; i <= m && i * s <= n; ++i)
f[i] = (ll)binom(m, i) * binom(n, i * s) % mod * gfac[i * s] % mod * mpow(gifac[s], i) % mod * mpow(m - i, n - i * s) % mod;
f = f.taylor(mod - 1);
for (int i = 0; i <= m; ++i) {
int coe;
scanf("%d", &coe);
fam(ans, coe, f[i]);
}
printf("%d\n", ans);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 2ms
memory: 3152kb
input:
6 3 3 875144946 539390293 1004054967 683158784
output:
475899516
result:
ok single line: '475899516'
Test #2:
score: 5
Accepted
time: 2ms
memory: 3128kb
input:
9 5 2 208428201 827196509 364419267 43911280 590362745 632512472
output:
221536757
result:
ok single line: '221536757'
Test #3:
score: 5
Accepted
time: 2ms
memory: 3128kb
input:
25 66 5 668744239 170429227 110443913 170293511 222442553 558856400 971723615 210836160 876630358 100744929 842761777 457483248 834588854 480589008 566626235 992038698 522534457 336252470 698914100 757697671 937897939 554376751 525885936 55630451 297992370 277492399 338353032 831948239 310968815 834...
output:
636054962
result:
ok single line: '636054962'
Test #4:
score: 5
Accepted
time: 2ms
memory: 3180kb
input:
39 86 2 990678220 745581427 234039709 499581733 455571981 251051305 791258708 975012067 510675921 452569855 138546670 204330675 2631453 595915164 974877701 257074330 1001313779 230355352 742883505 187053195 357989975 93414594 678858506 725973402 378916859 796838553 436884941 12661633 999138601 38920...
output:
971264764
result:
ok single line: '971264764'
Test #5:
score: 5
Accepted
time: 2ms
memory: 3176kb
input:
73 95 2 572399114 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
157290639
result:
ok single line: '157290639'
Test #6:
score: 5
Accepted
time: 2ms
memory: 3152kb
input:
48 27 2 978960943 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
output:
90018250
result:
ok single line: '90018250'
Test #7:
score: 5
Accepted
time: 5ms
memory: 4444kb
input:
80030 795 18 167068601 28791308 989271834 417854610 622151678 176964610 35678203 133455301 700058223 117834869 389020402 609668878 590005188 711445970 493797539 394989225 349955633 596825783 974827641 191553157 619845262 973777268 616999709 454621175 640675261 593178425 625678420 816415510 378433320...
output:
569816884
result:
ok single line: '569816884'
Test #8:
score: 5
Accepted
time: 34ms
memory: 10720kb
input:
90848 91700 48 579059315 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
28460727
result:
ok single line: '28460727'
Test #9:
score: 5
Accepted
time: 376ms
memory: 199392kb
input:
9034601 332 28 253189249 919299572 475200014 585495748 744412481 762841803 600420606 583650164 738857793 238860342 730569662 314290554 788668824 656274340 449494135 820022429 485479970 952467542 163515168 195175348 542034799 130328316 437388931 985901021 552621088 964296330 866978631 468126663 77142...
output:
602636366
result:
ok single line: '602636366'
Test #10:
score: 5
Accepted
time: 406ms
memory: 205348kb
input:
8652322 83136 65 792999908 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
946676169
result:
ok single line: '946676169'
Test #11:
score: 5
Accepted
time: 32ms
memory: 16764kb
input:
901984 26168 46 501746883 281172383 983760760 130557207 146531021 621999629 786515921 405905423 429665778 312327272 715173563 753530098 135965550 567180158 236556462 777603510 941855609 406643655 77932106 765423457 50047664 231291612 482487451 927688249 927394719 782080207 221927637 451855470 507967...
output:
71749865
result:
ok single line: '71749865'
Test #12:
score: 5
Accepted
time: 27ms
memory: 16672kb
input:
788473 24894 19 305866021 55140991 207676565 900030660 568610899 112828074 235582981 923783525 70613757 541024697 49552546 450187988 194985691 991655057 791247543 682620805 725380060 504147533 160993191 181734420 144862220 329090102 403772047 541780231 350357792 249762995 449773141 76557699 59862349...
output:
863231970
result:
ok single line: '863231970'
Test #13:
score: 5
Accepted
time: 42ms
memory: 21012kb
input:
965764 81550 43 411030316 611439926 55205896 818048176 990647676 171475021 956652998 920735229 147889279 396714775 377117166 800845553 760397049 988502359 124595396 223191015 435946310 227244529 116662892 391134354 972528485 867489316 734587791 134456883 719428570 281969038 267720516 505357542 93697...
output:
619874963
result:
ok single line: '619874963'
Test #14:
score: 5
Accepted
time: 44ms
memory: 21460kb
input:
634618 92393 46 527684078 472841311 656903476 813848304 362730735 70652539 931531214 629221555 331759947 882217242 582062490 129609907 458404873 92478752 724282104 51226312 742185267 215598556 73452464 900191238 754802465 722601726 941975464 632308509 411595003 113921692 319263708 816003140 99819896...
output:
402038185
result:
ok single line: '402038185'
Test #15:
score: 5
Accepted
time: 181ms
memory: 104364kb
input:
5307404 46001 82 378957151 323858701 500946596 720295874 122442546 851718922 255268380 360197744 318563539 771777395 121815884 975853721 407725158 447276198 460239753 513036640 246807093 69403291 230652449 263601303 134843504 426767945 108995632 603330217 244312248 30840058 541703442 260772027 72334...
output:
150923519
result:
ok single line: '150923519'
Test #16:
score: 5
Accepted
time: 158ms
memory: 102472kb
input:
8342876 23245 12 1003824029 766825866 412068083 936335906 355816149 492920531 102326114 340217147 324703790 285149577 111312005 314744290 972833376 789478606 403745563 346903345 782537132 784852270 770844776 619789244 243695327 311487143 485646603 907054367 815498528 279982518 719308946 797528552 17...
output:
653714877
result:
ok single line: '653714877'
Test #17:
score: 5
Accepted
time: 360ms
memory: 200760kb
input:
9986159 19889 145 397776078 738841879 461925703 665272644 828254723 92799686 80569549 376687918 175516510 831489926 527891210 575932290 615652035 860292772 450250507 966182595 927939877 619292840 252020819 311157863 888062791 414614475 783914670 654878905 836446384 249588328 726201066 787431826 1976...
output:
955546902
result:
ok single line: '955546902'
Test #18:
score: 5
Accepted
time: 204ms
memory: 107660kb
input:
6006718 97148 3 113796753 207819897 184203708 749588831 89674243 246509004 531607111 578225104 552765736 111602218 722526274 588218789 279052623 121257026 959926276 276729559 916403469 334220302 512560317 209980052 200201327 415648668 610987585 391573767 328657618 291754053 329575588 428719954 27552...
output:
394699692
result:
ok single line: '394699692'
Test #19:
score: 5
Accepted
time: 399ms
memory: 206000kb
input:
9841962 98900 100 212636488 818349493 984706715 148743221 405674506 691143429 981179164 301148443 322246994 983253043 752834007 353938042 176364230 210906231 268519551 995264808 548630297 49972123 661147508 403034853 676569168 593103579 636380771 145321043 388753634 494057129 246845503 573425425 741...
output:
863067655
result:
ok single line: '863067655'
Test #20:
score: 5
Accepted
time: 445ms
memory: 205612kb
input:
8538001 87072 36 847531982 855454517 155083213 82369594 432752363 591471883 269959303 392864068 990658065 242520317 829690978 127597550 869472573 925237811 596523272 447688096 549524044 492197156 681196956 944075049 578561987 199555315 7056377 122832171 978317158 267422663 139570686 735233948 693688...
output:
635784232
result:
ok single line: '635784232'