QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#930696 | #9651. 又一个欧拉数问题 | hos.lyric🐇# | 100 ✓ | 301ms | 41364kb | C++14 | 13.5kb | 2025-03-10 06:33:56 | 2025-03-10 06:33:56 |
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; }
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
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;
}
// m := |as|, n := |bs|
// cs[k] = \sum[i-j=k] as[i] bs[j] (0 <= k <= m-n)
// transpose of ((multiply by bs): K^[0,m-n] -> K^[0,m-1])
vector<Mint> middle(vector<Mint> as, vector<Mint> bs) {
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;
}
////////////////////////////////////////////////////////////////////////////////
constexpr int LIM_INV = 200'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, K;
Mint W[8];
int main() {
prepare();
for (; ~scanf("%d%d", &N, &K); ) {
--K;
for (int h = 0; h < 1 << K; ++h) {
scanf("%u", &W[h].x);
}
// 0: ?, 1: <
for (int k = 0; k < K; ++k) {
for (int h = 0; h < 1 << K; ++h) if (!(h & 1 << k)) {
W[h | 1 << k] -= W[h];
}
}
cerr<<"W = ";pv(W,W+(1<<K));
/*
f[u][v][j]: u -> v; <^j
g[u][v][j]: u -> v; <^(j-1) ?
*/
vector<Mint> f[4][4], g[4][4];
for (int u = 0; u < 1 << (K-1); ++u) for (int v = 0; v < 1 << (K-1); ++v) {
f[u][v].assign(N + 1, 0);
g[u][v].assign(N + 1, 0);
}
for (int u = 0; u < 1 << (K-1); ++u) {
f[u][u][0] += 1;
}
for (int u = 0; u < 1 << (K-1); ++u) {
for (int j = 0; j < N; ++j) {
for (int v = 0; v < 1 << (K-1); ++v) {
for (int h = 0; h < 1 << K; ++h) {
if ((v | h) & 1) {
f[u][(v | h) >> 1][j + 1] += f[u][v][j] * W[h];
} else {
g[u][(v | h) >> 1][j + 1] += f[u][v][j] * W[h];
}
}
}
}
}
vector<vector<Mint>> gg[4][4];
for (int u = 0; u < 1 << (K-1); ++u) for (int v = 0; v < 1 << (K-1); ++v) {
for (int e = 0; 1 << e <= 2*N; ++e) {
vector<Mint> gs(1 << e, 0);
for (int j = 0; j < 1 << e && j <= N; ++j) gs[j] = g[u][v][j] * invFac[j];
fft(gs);
gg[u][v].push_back(gs);
}
}
vector<Mint> dp[4];
for (int u = 0; u < 1 << (K-1); ++u) {
dp[u].assign(N - K + 1, 0);
}
dp[0][0] += 1;
for (int i = 1; i <= N - K; ++i) {
const int w = i & -i;
const int e = __builtin_ctz(w << 1);
vector<Mint> pss[4], qss[4];
for (int u = 0; u < 1 << (K-1); ++u) {
pss[u].assign(w << 1, 0);
for (int j = i - w; j < i; ++j) pss[u][j - (i - w)] = dp[u][j];
fft(pss[u]);
}
for (int u = 0; u < 1 << (K-1); ++u) {
qss[u].assign(w << 1, 0);
}
for (int u = 0; u < 1 << (K-1); ++u) for (int v = 0; v < 1 << (K-1); ++v) {
for (int j = 0; j < w << 1; ++j) qss[v][j] += pss[u][j] * gg[u][v][e][j];
}
for (int u = 0; u < 1 << (K-1); ++u) {
invFft(qss[u]);
for (int j = i; j < i + w && j <= N - K; ++j) dp[u][j] += qss[u][j - (i - w)];
}
}
Mint ans = 0;
for (int u = 0; u < 1 << (K-1); ++u) for (int v = 0; v < 1 << (K-1); ++v) {
for (int i = 0; i <= N - K; ++i) {
Mint t = dp[u][i] * f[u][v][(N - K) - i];
int w = v;
int j = (N - K) - i;
for (int k = 0; k < K - 1; ++k) {
if (w & 1) {
++j;
} else {
t *= invFac[j + 1];
j = 0;
}
w >>= 1;
}
t *= invFac[j + 1];
ans += t;
}
}
ans *= fac[N];
printf("%u\n", ans.x);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 3ms
memory: 6220kb
input:
4 4 698120943 122288832 680575548 463848799 156774757 854895700 608223343 677744207
output:
129451994
result:
ok 1 number(s): "129451994"
Test #2:
score: 5
Accepted
time: 2ms
memory: 6144kb
input:
5 4 550891357 916542306 749948554 123704496 62951279 389103312 185283715 952036050
output:
603530316
result:
ok 1 number(s): "603530316"
Test #3:
score: 5
Accepted
time: 2ms
memory: 6144kb
input:
5 4 0 0 0 0 0 0 0 0
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: 5
Accepted
time: 3ms
memory: 6272kb
input:
9 4 932794876 983187846 61110015 10089567 242406926 990649413 302889463 707289292
output:
623984278
result:
ok 1 number(s): "623984278"
Test #5:
score: 5
Accepted
time: 3ms
memory: 6016kb
input:
10 4 0 0 0 0 0 0 0 0
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 5
Accepted
time: 0ms
memory: 6212kb
input:
7 4 75656923 89231235 268411832 331473274 613621490 724088841 938061331 436247598
output:
828280933
result:
ok 1 number(s): "828280933"
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #7:
score: 10
Accepted
time: 3ms
memory: 6272kb
input:
17 4 502378168 0 899256313 98988040 502378168 899256313 495866185 403390128
output:
955634034
result:
ok 1 number(s): "955634034"
Test #8:
score: 10
Accepted
time: 2ms
memory: 6272kb
input:
12 4 973896694 511296006 0 486948347 0 0 486948347 511296006
output:
717853738
result:
ok 1 number(s): "717853738"
Test #9:
score: 10
Accepted
time: 0ms
memory: 6272kb
input:
19 4 0 0 0 0 0 0 0 0
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 10
Accepted
time: 0ms
memory: 6272kb
input:
11 4 419369069 674825741 201692543 290396938 869076983 225876646 409445596 934556751
output:
579300967
result:
ok 1 number(s): "579300967"
Test #11:
score: 10
Accepted
time: 2ms
memory: 6272kb
input:
16 4 399991278 671519396 535203044 718737955 71028311 806731162 326724957 940847965
output:
842945071
result:
ok 1 number(s): "842945071"
Test #12:
score: 10
Accepted
time: 3ms
memory: 6016kb
input:
17 4 836771329 338008804 131570815 515413785 262236691 408466186 362787701 152542617
output:
293433305
result:
ok 1 number(s): "293433305"
Subtask #3:
score: 5
Accepted
Test #13:
score: 5
Accepted
time: 2ms
memory: 6016kb
input:
2 2 0 0
output:
0
result:
ok 1 number(s): "0"
Test #14:
score: 5
Accepted
time: 2ms
memory: 6016kb
input:
3 2 0 142044554
output:
704013496
result:
ok 1 number(s): "704013496"
Test #15:
score: 5
Accepted
time: 1ms
memory: 6016kb
input:
4 2 0 0
output:
0
result:
ok 1 number(s): "0"
Test #16:
score: 5
Accepted
time: 2ms
memory: 6016kb
input:
5 2 0 0
output:
0
result:
ok 1 number(s): "0"
Test #17:
score: 5
Accepted
time: 46ms
memory: 9236kb
input:
99487 2 0 0
output:
0
result:
ok 1 number(s): "0"
Test #18:
score: 5
Accepted
time: 44ms
memory: 9236kb
input:
99738 2 693173587 283412622
output:
815899210
result:
ok 1 number(s): "815899210"
Subtask #4:
score: 10
Accepted
Test #19:
score: 10
Accepted
time: 2ms
memory: 6216kb
input:
3 3 977925087 204858071 813705548 204858071
output:
225177337
result:
ok 1 number(s): "225177337"
Test #20:
score: 10
Accepted
time: 3ms
memory: 6144kb
input:
4 3 455457192 542787161 728591379 0
output:
494572650
result:
ok 1 number(s): "494572650"
Test #21:
score: 10
Accepted
time: 2ms
memory: 6144kb
input:
5 3 280102847 175353772 822890581 718141506
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 10
Accepted
time: 2ms
memory: 6272kb
input:
93 3 517938077 480306276 173009841 0
output:
132737095
result:
ok 1 number(s): "132737095"
Test #23:
score: 10
Accepted
time: 1ms
memory: 6144kb
input:
85 3 812966373 8069068 241411799 241442405
output:
835292882
result:
ok 1 number(s): "835292882"
Test #24:
score: 10
Accepted
time: 1ms
memory: 6016kb
input:
93 3 740309863 562024812 723775833 67304547
output:
79626905
result:
ok 1 number(s): "79626905"
Subtask #5:
score: 10
Accepted
Dependency #4:
100%
Accepted
Test #25:
score: 10
Accepted
time: 2ms
memory: 6400kb
input:
3204 3 390926493 321900190 164112702 172373440
output:
25228045
result:
ok 1 number(s): "25228045"
Test #26:
score: 10
Accepted
time: 2ms
memory: 6272kb
input:
118 3 0 0 0 0
output:
0
result:
ok 1 number(s): "0"
Test #27:
score: 10
Accepted
time: 4ms
memory: 6400kb
input:
1812 3 743708154 0 458364972 539879381
output:
369996118
result:
ok 1 number(s): "369996118"
Test #28:
score: 10
Accepted
time: 4ms
memory: 6400kb
input:
3997 3 506494422 310846999 0 0
output:
180977771
result:
ok 1 number(s): "180977771"
Test #29:
score: 10
Accepted
time: 3ms
memory: 6400kb
input:
3919 3 850826367 581870616 262788170 385598679
output:
718155036
result:
ok 1 number(s): "718155036"
Test #30:
score: 10
Accepted
time: 3ms
memory: 6528kb
input:
3908 3 268833736 15860337 13324648 101653332
output:
307317750
result:
ok 1 number(s): "307317750"
Subtask #6:
score: 15
Accepted
Dependency #5:
100%
Accepted
Test #31:
score: 15
Accepted
time: 29ms
memory: 8576kb
input:
27617 3 649538421 649538421 697411864 348705932
output:
147599656
result:
ok 1 number(s): "147599656"
Test #32:
score: 15
Accepted
time: 26ms
memory: 8704kb
input:
32594 3 0 0 0 0
output:
0
result:
ok 1 number(s): "0"
Test #33:
score: 15
Accepted
time: 19ms
memory: 8268kb
input:
18203 3 971232001 436685091 53582375 579077060
output:
15944343
result:
ok 1 number(s): "15944343"
Test #34:
score: 15
Accepted
time: 40ms
memory: 10976kb
input:
39024 3 761026701 107837672 107837672 129379980
output:
733762036
result:
ok 1 number(s): "733762036"
Test #35:
score: 15
Accepted
time: 39ms
memory: 10920kb
input:
39934 3 860432642 218393709 0 137811711
output:
959310258
result:
ok 1 number(s): "959310258"
Test #36:
score: 15
Accepted
time: 41ms
memory: 10972kb
input:
39441 3 647870660 428771613 299764381 537645434
output:
403002156
result:
ok 1 number(s): "403002156"
Subtask #7:
score: 5
Accepted
Dependency #6:
100%
Accepted
Test #37:
score: 5
Accepted
time: 78ms
memory: 15428kb
input:
65961 3 573372243 470586592 899656037 952529871
output:
727883299
result:
ok 1 number(s): "727883299"
Test #38:
score: 5
Accepted
time: 101ms
memory: 16348kb
input:
95856 3 657353865 0 340890488 0
output:
443504623
result:
ok 1 number(s): "443504623"
Test #39:
score: 5
Accepted
time: 45ms
memory: 11096kb
input:
43044 3 735177548 164240636 263066805 263066805
output:
357165044
result:
ok 1 number(s): "357165044"
Test #40:
score: 5
Accepted
time: 106ms
memory: 16804kb
input:
99124 3 0 626743689 688853562 309390791
output:
488790683
result:
ok 1 number(s): "488790683"
Test #41:
score: 5
Accepted
time: 106ms
memory: 16756kb
input:
99895 3 599127905 0 269443581 399116448
output:
308060904
result:
ok 1 number(s): "308060904"
Test #42:
score: 5
Accepted
time: 108ms
memory: 16764kb
input:
99441 3 81228584 583326742 103263243 128429203
output:
142331215
result:
ok 1 number(s): "142331215"
Subtask #8:
score: 10
Accepted
Dependency #2:
100%
Accepted
Test #43:
score: 10
Accepted
time: 2ms
memory: 6088kb
input:
4 4 0 0 0 0 0 0 0 0
output:
0
result:
ok 1 number(s): "0"
Test #44:
score: 10
Accepted
time: 3ms
memory: 6272kb
input:
5 4 719850794 868458999 534771757 496641034 108328567 58126453 451622145 127965210
output:
199502123
result:
ok 1 number(s): "199502123"
Test #45:
score: 10
Accepted
time: 5ms
memory: 6688kb
input:
1620 4 575012072 993907457 465640749 414558489 536940500 884536134 536940500 579348968
output:
276727543
result:
ok 1 number(s): "276727543"
Test #46:
score: 10
Accepted
time: 6ms
memory: 6656kb
input:
2000 4 583522935 653359292 238637874 720209712 120795105 906170921 202280741 436530633
output:
247950749
result:
ok 1 number(s): "247950749"
Test #47:
score: 10
Accepted
time: 6ms
memory: 6784kb
input:
1903 4 0 0 0 0 0 0 0 0
output:
0
result:
ok 1 number(s): "0"
Test #48:
score: 10
Accepted
time: 7ms
memory: 6784kb
input:
1970 4 634852705 681848099 480528749 96325370 426074420 662814695 282626889 407588785
output:
358841946
result:
ok 1 number(s): "358841946"
Subtask #9:
score: 10
Accepted
Dependency #8:
100%
Accepted
Test #49:
score: 10
Accepted
time: 105ms
memory: 21820kb
input:
35788 4 137592553 167362125 666174864 893867308 935259273 409053348 908484962 421828880
output:
317183526
result:
ok 1 number(s): "317183526"
Test #50:
score: 10
Accepted
time: 31ms
memory: 10368kb
input:
13180 4 455644004 629655674 433939914 99482062 167912374 215744296 744048010 856909532
output:
724269763
result:
ok 1 number(s): "724269763"
Test #51:
score: 10
Accepted
time: 64ms
memory: 14820kb
input:
25810 4 50511582 266090813 782665122 316602395 681641958 25053907 922678864 732153540
output:
316456760
result:
ok 1 number(s): "316456760"
Test #52:
score: 10
Accepted
time: 112ms
memory: 22296kb
input:
39626 4 0 0 0 0 0 0 0 0
output:
0
result:
ok 1 number(s): "0"
Test #53:
score: 10
Accepted
time: 114ms
memory: 22384kb
input:
39520 4 304751689 247786932 175360249 662006566 300713484 967876352 912150432 961654612
output:
581564252
result:
ok 1 number(s): "581564252"
Test #54:
score: 10
Accepted
time: 120ms
memory: 22360kb
input:
39654 4 199691859 32920622 161790938 562758769 16726982 895821371 135168521 518536619
output:
389091873
result:
ok 1 number(s): "389091873"
Subtask #10:
score: 20
Accepted
Dependency #9:
100%
Accepted
Test #55:
score: 20
Accepted
time: 231ms
memory: 37032kb
input:
70610 4 68292738 168290466 829953887 829953887 168290466 929951615 99997728 829953887
output:
139356701
result:
ok 1 number(s): "139356701"
Test #56:
score: 20
Accepted
time: 258ms
memory: 38828kb
input:
83154 4 40222982 0 40222982 40222982 958021371 0 877575407 0
output:
810635777
result:
ok 1 number(s): "810635777"
Test #57:
score: 20
Accepted
time: 144ms
memory: 23920kb
input:
50832 4 105333371 857557033 892910982 260281951 843295773 154948580 892910982 892910982
output:
241653357
result:
ok 1 number(s): "241653357"
Test #58:
score: 20
Accepted
time: 299ms
memory: 41180kb
input:
99201 4 259092713 0 0 811163900 446173166 552071187 739151640 187080453
output:
150187101
result:
ok 1 number(s): "150187101"
Test #59:
score: 20
Accepted
time: 301ms
memory: 41364kb
input:
99797 4 367311954 251136106 555832002 724805462 945161134 244359464 684015618 92172056
output:
25758638
result:
ok 1 number(s): "25758638"
Test #60:
score: 20
Accepted
time: 299ms
memory: 41256kb
input:
99065 4 671004682 687177570 888521328 363461538 143576590 52815535 910840671 989086834
output:
379711332
result:
ok 1 number(s): "379711332"