QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#187094 | #4910. Numbers | hos_lyric | 78 | 565ms | 5088kb | C++14 | 6.8kb | 2023-09-24 14:32:20 | 2023-09-24 14:32:20 |
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 <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")
////////////////////////////////////////////////////////////////////////////////
// Barrett
struct ModInt {
static unsigned M;
static unsigned long long NEG_INV_M;
static void setM(unsigned long long m) { M = m; NEG_INV_M = -1ULL / M; }
unsigned x;
ModInt() : x(0U) {}
ModInt(unsigned x_) : x(x_ % M) {}
ModInt(unsigned long long x_) : x(x_ % M) {}
ModInt(int x_) : x(((x_ %= static_cast<int>(M)) < 0) ? (x_ + static_cast<int>(M)) : x_) {}
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) {
const unsigned long long y = static_cast<unsigned long long>(x) * a.x;
const unsigned long long q = static_cast<unsigned long long>((static_cast<unsigned __int128>(NEG_INV_M) * y) >> 64);
const unsigned long long r = y - M * q;
x = r - M * (r >= 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; }
};
unsigned ModInt::M;
unsigned long long ModInt::NEG_INV_M;
// !!!Use ModInt::setM!!!
////////////////////////////////////////////////////////////////////////////////
using Mint = ModInt;
/*
fix t != 0
F[u] := Pr[u -> t]
F[0] = 0
F[t] = 1
F[u] = \sum[i] P[i] F[u+e[i]] (u != 0, t)
F(x) = \sum[u] F[u] x^u
= x^t + \sum[u!=0,t] F[u] x^u
= x^t + \sum[u!=0,t] \sum[i] P[i] F[u+e[i]] x^u
= x^t + \sum[v] \sum[i] P[i] F[v] x^(v-e[i]) - \sum[i] P[i] F[e[i]] - \sum[i] P[i] F[t+e[i]] x^t
=: G(x) F(x) + a + b x^t
G(x) = \sum[i] P[i] x^(-i)
Pr[start -> t] = -a
F(1) = G(1) F(1) + a + b
G(1) = 1
b = -a
(1 - G(x)) F(x) = a (x^0 - x^t)
w: vector of roots of unity
H(w) = 1 - w^t
F(w) = (1 - w^t) / (1 - G(w)) (w != 1)
F(1) = -\sum[w!=1] F(w)
F[t] = (1/M) (F(1) + \sum[w!=1] w^-t F(w))
= (1/M) \sum[w!=1] (w^(-t) - 2 + w^t) / (1 - G(w))
*/
int N, MO, I;
vector<int> L;
vector<Mint> P, D;
int M;
vector<int> LL;
void dft(vector<Mint> &fs, bool inv) {
for (int i = 0; i < N; ++i) {
const Mint d = inv ? D[i].inv() : D[i];
for (int u = 0; u < M; u += LL[i + 1]) for (int v = u; v < u + LL[i]; ++v) {
vector<Mint> as(L[i]);
for (int k = 0; k < L[i]; ++k) as[k] = fs[v + k * LL[i]];
vector<Mint> bs(L[i], 0);
Mint dk = 1;
for (int k = 0; k < L[i]; ++k) {
Mint dkl = 1;
for (int l = 0; l < L[i]; ++l) {
bs[k] += dkl * as[l];
dkl *= dk;
}
dk *= d;
}
for (int k = 0; k < L[i]; ++k) fs[v + k * LL[i]] = bs[k];
}
}
if (inv) {
const Mint invM = Mint(M).inv();
for (int u = 0; u < M; ++u) {
fs[u] *= invM;
}
}
}
int main() {
for (; ~scanf("%d%d%d", &N, &MO, &I); ) {
Mint::setM(MO);
L.resize(N);
P.resize(N);
D.resize(N);
for (int i = 0; i < N; ++i) {
scanf("%d%u%u", &L[i], &P[i].x, &D[i].x);
}
{
Mint sumP = 0;
for (int i = 0; i < N; ++i) {
sumP += P[i];
}
const Mint invSumP = sumP.inv();
for (int i = 0; i < N; ++i) {
P[i] *= invSumP;
}
}
LL.resize(N + 1);
LL[0] = 1;
for (int i = 0; i < N; ++i) {
LL[i + 1] = LL[i] * L[i];
}
M = LL[N];
cerr<<"N = "<<N<<", M = "<<M<<", I = "<<I<<", L = "<<L<<endl;
vector<Mint> gs(M, 0);
gs[0] += 1;
for (int i = 0; i < N; ++i) {
gs[(L[i] - 1) * LL[i]] -= P[i];
}
dft(gs, false);
assert(!gs[0]);
for (int u = 1; u < M; ++u) {
assert(gs[u]);
gs[u] = gs[u].inv();
}
dft(gs, true);
Mint ans = 1;
for (int t = 1; t < M; ++t) {
int tt = 0;
for (int i = 0; i < N; ++i) {
tt += ((L[i] - t / LL[i] % L[i]) % L[i]) * LL[i];
}
const Mint f = gs[t] - 2 * gs[0] + gs[tt];
assert(f);
ans -= f.inv();
}
printf("%u\n", ans.x);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
1 1040016149 1 114514 86782 975423317
output:
result:
Subtask #2:
score: 8
Accepted
Test #2:
score: 8
Accepted
time: 0ms
memory: 3732kb
input:
1 917829557 2 7 409960 84299716
output:
7
result:
ok 1 number(s): "7"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
2 1021037011 2 3 673845 456586624 2 557323 1021037010
output:
325765596
result:
ok 1 number(s): "325765596"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
2 974672641 2 2 919159 974672640 4 945246 788001635
output:
206340059
result:
ok 1 number(s): "206340059"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
3 942949663 2 2 900268 942949662 2 314911 942949662 2 488210 942949662
output:
697012073
result:
ok 1 number(s): "697012073"
Subtask #3:
score: 10
Accepted
Dependency #2:
100%
Accepted
Test #6:
score: 10
Accepted
time: 0ms
memory: 3680kb
input:
2 1040469361 3 3 607396 156553896 20 622587 835710357
output:
212836966
result:
ok 1 number(s): "212836966"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
6 932284961 3 2 976786 932284960 2 296977 932284960 2 640048 932284960 2 883210 932284960 2 178849 932284960 2 292747 932284960
output:
767388139
result:
ok 1 number(s): "767388139"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
3 972511489 3 4 270846 275326774 6 901035 3644392 3 450749 3644391
output:
386017324
result:
ok 1 number(s): "386017324"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
4 952654361 3 4 353315 567578568 2 265582 952654360 2 429959 952654360 5 62389 840524015
output:
942289666
result:
ok 1 number(s): "942289666"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
3 969859729 3 3 342202 745159492 9 270897 686337727 3 216159 745159492
output:
184152966
result:
ok 1 number(s): "184152966"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
3 953647801 3 7 943891 755724372 4 151642 109446108 3 775757 89434891
output:
811899700
result:
ok 1 number(s): "811899700"
Test #12:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
3 1029304937 3 4 54303 379091496 2 193487 1029304936 11 607170 762447147
output:
626421900
result:
ok 1 number(s): "626421900"
Test #13:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
3 904885561 3 3 554090 196965144 2 945499 904885560 15 747460 217098071
output:
676301027
result:
ok 1 number(s): "676301027"
Test #14:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
6 986788531 3 2 522554 986788530 2 316305 986788530 2 94022 986788530 2 249256 986788530 2 625960 986788530 3 405298 837112629
output:
441366932
result:
ok 1 number(s): "441366932"
Test #15:
score: 0
Accepted
time: 1ms
memory: 3732kb
input:
2 1023351421 3 20 337665 403345072 5 40276 480359844
output:
1002751099
result:
ok 1 number(s): "1002751099"
Subtask #4:
score: 8
Accepted
Test #16:
score: 8
Accepted
time: 0ms
memory: 3688kb
input:
2 998244353 4 4 61786 911660635 238 287234 493901365
output:
223055892
result:
ok 1 number(s): "223055892"
Test #17:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
2 998244353 4 7 25813 683624219 112 96355 961521397
output:
97474170
result:
ok 1 number(s): "97474170"
Test #18:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
2 998244353 4 56 87114 727469702 14 24912 983690962
output:
592417090
result:
ok 1 number(s): "592417090"
Test #19:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
2 998244353 4 32 147776 617152567 28 775643 859007132
output:
566596649
result:
ok 1 number(s): "566596649"
Test #20:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
2 998244353 4 17 545281 464157011 56 816599 3898319
output:
469481867
result:
ok 1 number(s): "469481867"
Subtask #5:
score: 10
Accepted
Test #21:
score: 10
Accepted
time: 1ms
memory: 3672kb
input:
7 1023063703 5 2 265354 1023063702 2 526733 1023063702 2 685323 1023063702 2 856929 1023063702 2 116643 1023063702 2 909182 1023063702 2 533391 1023063702
output:
72258463
result:
ok 1 number(s): "72258463"
Test #22:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
8 909973201 5 2 803753 909973200 2 909951 909973200 2 686418 909973200 2 751586 909973200 2 596938 909973200 2 931460 909973200 2 613477 909973200 2 716815 909973200
output:
446664445
result:
ok 1 number(s): "446664445"
Test #23:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
9 1016555329 5 2 955958 1016555328 2 672234 1016555328 2 870436 1016555328 2 31291 1016555328 2 206731 1016555328 2 727640 1016555328 2 134125 1016555328 2 893866 1016555328 2 138706 1016555328
output:
808692189
result:
ok 1 number(s): "808692189"
Test #24:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
10 1007394217 5 2 961834 1007394216 2 209391 1007394216 2 715582 1007394216 2 553353 1007394216 2 213960 1007394216 2 589617 1007394216 2 666503 1007394216 2 407731 1007394216 2 152967 1007394216 2 848445 1007394216
output:
9280802
result:
ok 1 number(s): "9280802"
Test #25:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
10 968522221 5 2 21932 968522220 2 675564 968522220 2 378437 968522220 2 81037 968522220 2 963992 968522220 2 311430 968522220 2 699121 968522220 2 45417 968522220 2 275308 968522220 2 411066 968522220
output:
692011298
result:
ok 1 number(s): "692011298"
Subtask #6:
score: 12
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Test #26:
score: 12
Accepted
time: 0ms
memory: 3700kb
input:
4 972401761 6 2 972661 972401760 15 255992 126248662 12 878880 606133410 2 224371 972401760
output:
115576065
result:
ok 1 number(s): "115576065"
Test #27:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
4 904442113 6 4 455381 759185044 32 370753 618464921 3 500887 212337160 2 124789 904442112
output:
423186989
result:
ok 1 number(s): "423186989"
Test #28:
score: 0
Accepted
time: 2ms
memory: 3720kb
input:
2 1044288001 6 200 909466 831914154 4 635879 349141366
output:
992703804
result:
ok 1 number(s): "992703804"
Test #29:
score: 0
Accepted
time: 3ms
memory: 3696kb
input:
3 995557889 6 208 995170 150328412 2 962966 995557888 2 870197 995557888
output:
559608682
result:
ok 1 number(s): "559608682"
Test #30:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
3 926933113 6 4 600105 859154928 24 395570 903534782 9 869027 266882176
output:
586077830
result:
ok 1 number(s): "586077830"
Test #31:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
4 1018608697 6 28 136320 512857858 2 391617 1018608696 2 416876 1018608696 8 640950 421343802
output:
275871736
result:
ok 1 number(s): "275871736"
Test #32:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
5 909759601 6 10 839897 853552356 2 969093 909759600 4 795795 674156232 2 423545 909759600 6 600787 419741593
output:
241411297
result:
ok 1 number(s): "241411297"
Test #33:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
4 998016823 6 27 155873 262940187 2 158035 998016822 9 202421 553668428 2 21539 998016822
output:
118420215
result:
ok 1 number(s): "118420215"
Test #34:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
4 910702297 6 3 890425 906157449 24 469847 206340805 2 422607 910702296 7 67244 714860697
output:
836808927
result:
ok 1 number(s): "836808927"
Test #35:
score: 0
Accepted
time: 3ms
memory: 3684kb
input:
2 965490689 6 4 468310 246473372 256 256288 754419658
output:
20502222
result:
ok 1 number(s): "20502222"
Subtask #7:
score: 8
Accepted
Dependency #6:
100%
Accepted
Test #36:
score: 8
Accepted
time: 11ms
memory: 3800kb
input:
4 1040169409 7 2 835454 1040169408 3 772774 636723579 4 342482 586400067 192 334236 48598666
output:
836620519
result:
ok 1 number(s): "836620519"
Test #37:
score: 0
Accepted
time: 4ms
memory: 3700kb
input:
5 1001291201 7 2 380607 1001291200 8 447454 176535093 32 876312 112032651 5 769899 24926973 2 833606 1001291200
output:
773216067
result:
ok 1 number(s): "773216067"
Test #38:
score: 0
Accepted
time: 5ms
memory: 3708kb
input:
3 1027170721 7 108 162949 530583958 8 335705 915297592 6 762677 864984184
output:
944135384
result:
ok 1 number(s): "944135384"
Test #39:
score: 0
Accepted
time: 39ms
memory: 3752kb
input:
4 965986561 7 672 958339 534727307 2 543173 965986560 2 884696 965986560 2 78668 965986560
output:
731390335
result:
ok 1 number(s): "731390335"
Test #40:
score: 0
Accepted
time: 5ms
memory: 3752kb
input:
5 1033312897 7 2 847300 1033312896 22 496446 176836498 4 545327 842729668 4 825711 842729668 8 55521 221623844
output:
111025694
result:
ok 1 number(s): "111025694"
Test #41:
score: 0
Accepted
time: 7ms
memory: 3752kb
input:
4 974073601 7 80 688089 65481914 6 743381 676241902 2 457097 974073600 6 433647 676241902
output:
20654041
result:
ok 1 number(s): "20654041"
Test #42:
score: 0
Accepted
time: 15ms
memory: 3756kb
input:
4 988969921 7 192 682290 823722245 2 231872 988969920 4 644835 908425877 4 599428 80544044
output:
327364135
result:
ok 1 number(s): "327364135"
Test #43:
score: 0
Accepted
time: 3ms
memory: 3780kb
input:
4 905233921 7 10 797498 529875391 40 404554 190390703 8 51869 591750273 2 267795 905233920
output:
840539530
result:
ok 1 number(s): "840539530"
Test #44:
score: 0
Accepted
time: 6ms
memory: 3728kb
input:
4 995124209 7 8 15181 811988629 4 25011 700264330 4 29108 700264330 52 401060 745256833
output:
704350003
result:
ok 1 number(s): "704350003"
Test #45:
score: 0
Accepted
time: 8ms
memory: 3708kb
input:
3 942316129 7 12 857153 473633986 72 777888 329202798 8 483455 869896725
output:
388869095
result:
ok 1 number(s): "388869095"
Test #46:
score: 0
Accepted
time: 68ms
memory: 3704kb
input:
3 1035901441 7 896 435538 726832882 4 15200 453561200 2 924673 1035901440
output:
938917469
result:
ok 1 number(s): "938917469"
Test #47:
score: 0
Accepted
time: 152ms
memory: 3740kb
input:
2 1019232001 7 4 673885 248868967 1920 754816 341141141
output:
476117109
result:
ok 1 number(s): "476117109"
Test #48:
score: 0
Accepted
time: 308ms
memory: 3788kb
input:
2 957116737 7 3888 412700 63632954 2 333017 957116736
output:
21716613
result:
ok 1 number(s): "21716613"
Test #49:
score: 0
Accepted
time: 16ms
memory: 3716kb
input:
2 1018688833 7 168 928533 47528245 48 431265 446651888
output:
377651323
result:
ok 1 number(s): "377651323"
Test #50:
score: 0
Accepted
time: 172ms
memory: 3728kb
input:
2 930680833 7 2048 213064 343165841 4 619665 206937758
output:
710731553
result:
ok 1 number(s): "710731553"
Subtask #8:
score: 0
Time Limit Exceeded
Dependency #4:
100%
Accepted
Test #51:
score: 0
Time Limit Exceeded
input:
2 998244353 8 229376 553453 626702417 2 148397 998244352
output:
result:
Subtask #9:
score: 0
Skipped
Dependency #8:
0%
Subtask #10:
score: 10
Accepted
Dependency #5:
100%
Accepted
Test #71:
score: 10
Accepted
time: 27ms
memory: 3688kb
input:
15 969740263 10 2 373621 969740262 2 946569 969740262 2 253224 969740262 2 664561 969740262 2 611912 969740262 2 204304 969740262 2 746434 969740262 2 336578 969740262 2 200784 969740262 2 557632 969740262 2 651211 969740262 2 559106 969740262 2 610198 969740262 2 799763 969740262 2 908557 969740262
output:
411647692
result:
ok 1 number(s): "411647692"
Test #72:
score: 0
Accepted
time: 64ms
memory: 3676kb
input:
16 991926851 10 2 712792 991926850 2 396612 991926850 2 850616 991926850 2 678097 991926850 2 939368 991926850 2 978032 991926850 2 226041 991926850 2 545440 991926850 2 261283 991926850 2 142065 991926850 2 350488 991926850 2 915911 991926850 2 355737 991926850 2 57300 991926850 2 584284 991926850 ...
output:
529574589
result:
ok 1 number(s): "529574589"
Test #73:
score: 0
Accepted
time: 131ms
memory: 3768kb
input:
17 1004734669 10 2 774339 1004734668 2 761099 1004734668 2 350815 1004734668 2 956243 1004734668 2 13259 1004734668 2 547506 1004734668 2 459082 1004734668 2 817986 1004734668 2 724570 1004734668 2 935942 1004734668 2 560680 1004734668 2 520194 1004734668 2 260207 1004734668 2 852274 1004734668 2 56...
output:
426830028
result:
ok 1 number(s): "426830028"
Test #74:
score: 0
Accepted
time: 283ms
memory: 4200kb
input:
18 934497901 10 2 116198 934497900 2 820160 934497900 2 77657 934497900 2 611949 934497900 2 498059 934497900 2 471331 934497900 2 90116 934497900 2 413650 934497900 2 938011 934497900 2 455321 934497900 2 808088 934497900 2 467664 934497900 2 1790 934497900 2 746901 934497900 2 649412 934497900 2 9...
output:
132988262
result:
ok 1 number(s): "132988262"
Test #75:
score: 0
Accepted
time: 284ms
memory: 4324kb
input:
18 997115969 10 2 677091 997115968 2 182601 997115968 2 859073 997115968 2 844740 997115968 2 486819 997115968 2 239614 997115968 2 605204 997115968 2 108805 997115968 2 547452 997115968 2 78461 997115968 2 662608 997115968 2 930644 997115968 2 950692 997115968 2 223335 997115968 2 405750 997115968 ...
output:
576918483
result:
ok 1 number(s): "576918483"
Subtask #11:
score: 12
Accepted
Dependency #10:
100%
Accepted
Test #76:
score: 12
Accepted
time: 223ms
memory: 3972kb
input:
4 1032431401 11 22 699510 258557651 35 925197 147665025 12 561090 444222341 22 908847 573733633
output:
99475181
result:
ok 1 number(s): "99475181"
Test #77:
score: 0
Accepted
time: 279ms
memory: 4304kb
input:
5 990258361 11 26 569351 462961367 6 80029 91923647 28 860702 695739176 13 338538 474254325 5 292764 939161661
output:
153420054
result:
ok 1 number(s): "153420054"
Test #78:
score: 0
Accepted
time: 323ms
memory: 4548kb
input:
5 942013381 11 11 779531 345150756 6 675857 348180154 5 505879 317895062 22 723269 596862625 42 880286 229109913
output:
402752746
result:
ok 1 number(s): "402752746"
Test #79:
score: 0
Accepted
time: 476ms
memory: 4736kb
input:
5 962729461 11 3 778362 370070893 10 605034 216793322 11 337490 739455560 28 33633 871490348 44 355775 427272628
output:
591659186
result:
ok 1 number(s): "591659186"
Test #80:
score: 0
Accepted
time: 340ms
memory: 5048kb
input:
6 980201041 11 6 509634 440462155 4 665806 169208619 13 174944 769308185 13 802268 979901095 7 735659 594468251 15 716016 587533173
output:
196440161
result:
ok 1 number(s): "196440161"
Test #81:
score: 0
Accepted
time: 524ms
memory: 5068kb
input:
5 1006335331 11 33 465476 412382195 26 62659 649367959 10 379814 435149835 26 32613 193899237 2 362546 1006335330
output:
767433541
result:
ok 1 number(s): "767433541"
Test #82:
score: 0
Accepted
time: 464ms
memory: 5028kb
input:
7 1025362801 11 2 103702 1025362800 3 230121 393065710 3 866490 393065710 5 996945 438528644 7 75346 889862126 22 727767 723881393 33 744345 331906350
output:
624948293
result:
ok 1 number(s): "624948293"
Test #83:
score: 0
Accepted
time: 565ms
memory: 5088kb
input:
6 927400321 11 34 690193 633272049 14 271947 158466609 5 29155 48767577 3 680991 558580854 34 504089 50083535 2 269784 927400320
output:
529445988
result:
ok 1 number(s): "529445988"
Test #84:
score: 0
Accepted
time: 224ms
memory: 4220kb
input:
6 1026720001 11 5 856582 192380835 4 275465 826256064 2 577506 1026720000 30 726584 514798836 8 226229 122245655 24 708136 70845584
output:
196483828
result:
ok 1 number(s): "196483828"
Test #85:
score: 0
Accepted
time: 351ms
memory: 4464kb
input:
7 1048614337 11 8 81957 714673501 28 132495 421563936 2 981004 1048614336 2 730100 1048614336 2 504455 1048614336 42 710077 567746601 4 890757 467835333
output:
717647484
result:
ok 1 number(s): "717647484"
Test #86:
score: 0
Accepted
time: 323ms
memory: 4584kb
input:
6 1048924801 11 10 89570 521413525 4 496152 501406936 2 700711 1048924800 8 812007 592618035 48 653132 179779517 10 998767 343279042
output:
956663514
result:
ok 1 number(s): "956663514"
Test #87:
score: 0
Accepted
time: 384ms
memory: 4576kb
input:
5 1010095921 11 6 530393 687121127 30 440107 843763139 12 684275 324267076 4 691228 475079850 40 649981 506902675
output:
525817982
result:
ok 1 number(s): "525817982"
Test #88:
score: 0
Accepted
time: 376ms
memory: 4836kb
input:
7 935718661 11 20 799816 725732576 4 922930 747355853 2 463829 935718660 2 766609 935718660 4 175830 747355853 15 238560 611128660 20 768805 48007705
output:
339402274
result:
ok 1 number(s): "339402274"
Test #89:
score: 0
Accepted
time: 449ms
memory: 5024kb
input:
7 904611457 11 3 896340 681718948 4 145563 9216110 8 315633 570585560 42 124915 772177444 2 790943 904611456 7 756555 392957847 8 680504 387697417
output:
513967674
result:
ok 1 number(s): "513967674"
Test #90:
score: 0
Accepted
time: 404ms
memory: 4996kb
input:
7 954670081 11 2 181551 954670080 6 601961 633710667 20 415802 518488008 16 36518 470515757 6 527605 633710667 2 772131 954670080 10 592493 212387045
output:
845226312
result:
ok 1 number(s): "845226312"
Subtask #12:
score: 0
Skipped
Dependency #7:
100%
Accepted
Dependency #9:
0%