QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#708210 | #1883. Rational Dimasik | hcywoi | AC ✓ | 175ms | 44852kb | C++23 | 4.9kb | 2024-11-03 20:24:24 | 2024-11-03 20:24:25 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
template<class T>
T qmi(T a, i64 b) {
T res = 1;
for (; b; b /= 2, a *= a) {
if (b % 2) {
res *= a;
}
}
return res;
}
i64 mul(i64 a, i64 b, i64 p) {
i64 res = a * b - i64(1.L * a * b / p) * p;
res %= p;
if (res < 0) {
res += p;
}
return res;
}
template<int P>
struct modint {
int x;
constexpr modint() : x{} {}
constexpr modint(i64 x) : x{norm(x % getmod())} {}
static int mod;
constexpr static int getmod() {
if (P > 0) {
return P;
} else {
return mod;
}
}
constexpr static void setmod(int m) {
mod = m;
}
constexpr int norm(int x) const {
if (x < 0) {
x += getmod();
}
if (x >= getmod()) {
x -= getmod();
}
return x;
}
constexpr int val() const {
return x;
}
explicit constexpr operator int() const {
return x;
}
constexpr modint operator-() const {
modint res;
res.x = norm(getmod() - x);
return res;
}
constexpr modint inv() const {
assert(x != 0);
return qmi(*this, getmod() - 2);
}
constexpr modint &operator*= (modint v) & {
x = 1LL * x * v.x % getmod();
return *this;
}
constexpr modint &operator+= (modint v) & {
x = norm(x + v.x);
return *this;
}
constexpr modint &operator-= (modint v) & {
x = norm(x - v.x);
return *this;
}
constexpr modint &operator/= (modint v) & {
return *this *= v.inv();
}
friend constexpr modint operator- (modint a, modint b) {
modint res = a;
res -= b;
return res;
}
friend constexpr modint operator+ (modint a, modint b) {
modint res = a;
res += b;
return res;
}
friend constexpr modint operator* (modint a, modint b) {
modint res = a;
res *= b;
return res;
}
friend constexpr modint operator/ (modint a, modint b) {
modint res = a;
res /= b;
return res;
}
friend constexpr std::istream &operator>> (std::istream& is, modint& a) {
i64 v;
is >> v;
a = modint(v);
return is;
}
friend constexpr std::ostream &operator<< (std::ostream& os, const modint& a) {
return os << a.val();
}
friend constexpr bool operator== (modint a, modint b) {
return a.val() == b.val();
}
friend constexpr bool operator!= (modint a, modint b) {
return a.val() != b.val();
}
};
constexpr int P = 998244353;
using mint = modint<P>;
std::vector<int> minp, primes;
void sieve(int n) {
minp.assign(n + 1, 0);
primes.clear();
for (int i = 2; i <= n; i++) {
if (minp[i] == 0) {
minp[i] = i;
primes.push_back(i);
}
for (auto p : primes) {
if (i * p > n) {
break;
}
minp[i * p] = p;
if (p == minp[i]) {
break;
}
}
}
}
int exgcd(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1, y = 0;
return a;
}
int d = exgcd(b, a % b, y, x);
y -= a / b * x;
return d;
}
int inv(int a, int p) {
int x, y;
exgcd(a, p, x, y);
return (x % p + p) % p;
}
int main() {
// freopen("number.in", "r", stdin);
// freopen("number.out", "w", stdout);
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> a(n), b(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i] >> b[i];
int d = std::__gcd(a[i], b[i]);
a[i] /= d;
b[i] /= d;
}
const int V = 1E6;
sieve(V);
std::vector<std::vector<std::array<int, 3>>> vec(V + 1);
for (int i = 0; i < n; i++) {
int x = b[i];
while (x > 1) {
int cur = 0;
int p = minp[x], mul = 1;
while (x % p == 0) {
x /= p;
mul *= p;
cur++;
}
vec[p].push_back({cur, b[i] / mul, i});
}
}
mint ans = 1;
std::vector<int> cnt(V + 1);
for (auto p : primes) {
std::sort(vec[p].begin(), vec[p].end(), std::greater());
int m = vec[p].size();
for (int i = 0; i < m; i++) {
int j = i;
while (j < m && vec[p][i][0] == vec[p][j][0]) {
j++;
}
int K = vec[p][i][0];
ans *= qmi(mint(p), 1LL * K * i * (j - i));
int np = 1;
i64 tot = 0;
for (int nk = 1; nk <= K; nk++) {
np *= p;
for (int l = i; l < j; l++) {
auto [_, na, id] = vec[p][l];
na = inv(na, np);
na = 1LL * na * a[id] % np;
tot += cnt[na];
cnt[na]++;
}
for (int l = i; l < j; l++) {
auto [_, na, id] = vec[p][l];
na = inv(na, np);
na = 1LL * na * a[id] % np;
cnt[na]--;
}
}
i64 w = 1LL * (j - i) * (j - i - 1) / 2;
ans *= qmi(mint(p), K * w + tot);
i = j - 1;
}
}
ans = ans.inv();
for (int i = 0; i < n; i++) {
ans *= qmi(mint(b[i]), n - 1);
}
std::cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 34784kb
input:
2 1 3 3 7
output:
21
result:
ok 1 number(s): "21"
Test #2:
score: 0
Accepted
time: 0ms
memory: 34764kb
input:
3 3 2 7 15 5 12
output:
7200
result:
ok 1 number(s): "7200"
Test #3:
score: 0
Accepted
time: 7ms
memory: 34796kb
input:
1 88 10
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 10ms
memory: 34848kb
input:
5 10 6 1 3 19 14 15 19 0 1
output:
277965528
result:
ok 1 number(s): "277965528"
Test #5:
score: 0
Accepted
time: 2ms
memory: 34920kb
input:
5 6 10 9 1 7 3 5 7 6 3
output:
121550625
result:
ok 1 number(s): "121550625"
Test #6:
score: 0
Accepted
time: 3ms
memory: 34740kb
input:
5 19 10 5 15 9 16 2 15 13 5
output:
886871776
result:
ok 1 number(s): "886871776"
Test #7:
score: 0
Accepted
time: 14ms
memory: 34764kb
input:
5 67992482 706200 707073690 185179 107778771 851180 622831676 200791 626191748 250174
output:
784265956
result:
ok 1 number(s): "784265956"
Test #8:
score: 0
Accepted
time: 3ms
memory: 34764kb
input:
5 950282372 222340 42580207 847361 133122113 554149 760063751 384779 474429532 554357
output:
126661804
result:
ok 1 number(s): "126661804"
Test #9:
score: 0
Accepted
time: 4ms
memory: 34732kb
input:
5 422506844 771185 41650236 701030 527061674 32925 307361242 568767 732732734 858539
output:
773906695
result:
ok 1 number(s): "773906695"
Test #10:
score: 0
Accepted
time: 9ms
memory: 34740kb
input:
20 47 1 60 32 94 94 62 10 59 55 25 81 81 69 95 52 99 79 29 57 31 89 21 75 87 17 34 29 49 45 85 80 67 23 51 41 38 48 89 69
output:
295626701
result:
ok 1 number(s): "295626701"
Test #11:
score: 0
Accepted
time: 3ms
memory: 34692kb
input:
20 25 42 81 14 49 71 6 94 51 41 93 21 90 2 82 73 60 38 81 6 73 67 63 58 62 25 81 86 10 11 62 51 81 52 56 49 31 15 51 87
output:
625429032
result:
ok 1 number(s): "625429032"
Test #12:
score: 0
Accepted
time: 9ms
memory: 34824kb
input:
20 3 86 90 91 3 48 63 86 9 19 24 65 65 39 45 90 56 88 65 51 24 53 16 41 4 41 26 43 93 81 83 33 5 88 85 58 23 90 23 94
output:
323980464
result:
ok 1 number(s): "323980464"
Test #13:
score: 0
Accepted
time: 8ms
memory: 34804kb
input:
20 811944684 474386 480680065 376101 44684613 563040 26931079 934158 968305812 410103 140560601 590118 618150532 795941 410010400 604618 268616835 790647 241566432 41948 262128553 828352 463193350 167617 122179603 337113 503009695 827746 870167729 856731 62318871 432940 191847739 437159 146581499 93...
output:
757820458
result:
ok 1 number(s): "757820458"
Test #14:
score: 0
Accepted
time: 9ms
memory: 34844kb
input:
20 989201865 23231 479750093 38283 70027955 233305 869195864 150850 521576305 714286 647137634 117157 621019177 365478 953771465 276727 819768234 70909 109336340 81997 681151291 751938 365159902 42000 468304065 455833 801318564 252607 612719218 156601 553599307 975914 99515091 380591 634650132 46348...
output:
128921183
result:
ok 1 number(s): "128921183"
Test #15:
score: 0
Accepted
time: 10ms
memory: 34740kb
input:
20 871491755 539371 110223902 891953 463967516 712081 711460647 302134 369814089 18468 448681957 452709 918855113 191911 276194166 724644 412388830 542659 682138957 346238 100174027 932420 972159163 883679 593090163 766041 99627432 710172 18834217 423768 118508670 229288 670745955 356727 491314983 5...
output:
129275688
result:
ok 1 number(s): "129275688"
Test #16:
score: 0
Accepted
time: 11ms
memory: 35100kb
input:
7000 355052 819015 988084 99827 193850 599865 23587 702712 397032 74851 945391 526688 27517 693363 422410 415451 821818 177084 345092 553661 973239 595635 379498 862015 268304 629875 718915 712123 293147 112122 826188 649715 902724 304042 798263 607562 117900 749513 855768 160009 359867 268353 94082...
output:
834475394
result:
ok 1 number(s): "834475394"
Test #17:
score: 0
Accepted
time: 9ms
memory: 35132kb
input:
7000 233123 367860 20344 953497 402538 302834 479344 919404 333664 346329 963874 53728 351634 487092 774685 896073 622945 457346 933570 626414 750879 743413 182634 927886 862328 715891 875208 361176 282323 411992 827883 968497 764549 280178 77723 945266 669857 946884 471065 917416 357415 853764 5422...
output:
650781682
result:
ok 1 number(s): "650781682"
Test #18:
score: 0
Accepted
time: 12ms
memory: 35124kb
input:
7000 37196 884000 15607 615678 648226 781611 972785 103392 270295 650511 982356 613472 638753 56630 238641 343990 461757 961800 559046 890655 603201 666999 948773 802269 493350 58804 31501 786037 309182 711863 792578 446064 662687 223611 357183 572571 221814 176959 49362 483335 354278 247686 181305 ...
output:
883306584
result:
ok 1 number(s): "883306584"
Test #19:
score: 0
Accepted
time: 120ms
memory: 43824kb
input:
200000 315853325 556680 626976528 921489 174033489 297467 821121372 262031 787592383 625894 85854372 520174 244257812 30830 666743786 484102 358169101 871227 397213041 248435 620501557 529660 582355366 528722 980684501 622241 32122877 709896 337419042 887199 427184000 798907 817849968 99120 82362339...
output:
799230347
result:
ok 1 number(s): "799230347"
Test #20:
score: 0
Accepted
time: 110ms
memory: 43804kb
input:
200000 198143214 105524 962483046 775159 567973051 743540 663386155 478723 340862876 930076 887398696 47214 878530238 600367 915537559 964724 540724280 118785 633579169 545380 113153222 453246 484321919 403105 326808962 965153 330431746 167461 79970531 187069 213431727 52281 20484611 42552 311692028...
output:
922715420
result:
ok 1 number(s): "922715420"
Test #21:
score: 0
Accepted
time: 127ms
memory: 43976kb
input:
200000 670367687 397473 961553074 404636 593316393 222317 874247159 662711 189100660 266962 688943020 415469 176366173 426800 164331331 412641 91875678 623240 911414494 809620 237208667 601023 386288471 501681 672933424 275361 923707907 783810 191118239 454236 73308382 595256 296748183 18688 1683568...
output:
414061474
result:
ok 1 number(s): "414061474"
Test #22:
score: 0
Accepted
time: 127ms
memory: 44296kb
input:
200000 552657576 946317 592026883 66818 987255954 892581 421544650 813995 37338445 538441 195520051 942509 474202109 996337 781721324 84750 274430858 903502 779184402 882373 656231405 748801 288255023 343360 724090594 361378 222016775 208671 302265947 721402 564588819 881334 573011755 929417 2463600...
output:
837772833
result:
ok 1 number(s): "837772833"
Test #23:
score: 0
Accepted
time: 127ms
memory: 44092kb
input:
200000 434947465 495161 296129619 696296 381195515 371358 558776725 30687 590608938 842623 628468156 502253 772038045 822771 30515096 532667 235647673 342548 646954311 146614 443850361 929283 526658065 217743 70215055 671586 520325644 666236 44817436 21272 55869254 358901 144242618 905553 734428728 ...
output:
165050323
result:
ok 1 number(s): "165050323"
Test #24:
score: 0
Accepted
time: 130ms
memory: 43992kb
input:
200000 612204646 44006 631636137 582669 406538856 850135 474670436 181971 70250503 179509 430012480 29292 69873981 392308 647905089 980584 418202853 622810 219756927 443559 567905807 820165 723591909 59422 416339517 47202 113601804 315289 450932436 321143 915745910 644979 51909971 848985 591093580 1...
output:
237630260
result:
ok 1 number(s): "237630260"
Test #25:
score: 0
Accepted
time: 122ms
memory: 43848kb
input:
200000 789461827 592850 262109946 212147 800478418 520400 316935220 398663 918488288 450988 231556803 364844 367709917 218741 896698862 428501 969354252 870369 87526835 483607 986928544 967942 625558461 933805 762463979 133218 780506894 707445 898516633 621013 407026345 187953 623140835 825122 37412...
output:
407963617
result:
ok 1 number(s): "407963617"
Test #26:
score: 0
Accepted
time: 124ms
memory: 44016kb
input:
200000 966719008 141694 261179974 874328 120789050 999177 527796223 582651 766726072 755170 33101127 924588 370578561 45174 514088854 909122 151909431 374823 955296744 747848 405951281 115720 527525013 999677 518653857 443427 783848471 165010 304631633 888179 898306781 441328 899404407 768554 862198...
output:
181365549
result:
ok 1 number(s): "181365549"
Test #27:
score: 0
Accepted
time: 126ms
memory: 43816kb
input:
200000 849008897 433643 891653784 503806 514728612 477954 370061006 766639 25029273 92056 539678159 484331 299818277 647416 762882627 581231 703060830 622381 233132068 44793 193570237 39306 60895346 874060 864778319 753635 377124631 814063 47183121 963857 758183436 951598 807071759 744691 940201352 ...
output:
672070816
result:
ok 1 number(s): "672070816"
Test #28:
score: 0
Accepted
time: 129ms
memory: 44244kb
input:
200000 145436064 860400 948877322 644825 482618919 598028 333242312 88443 992297037 530646 697718759 260985 770253434 591397 588728445 967538 645833578 923908 256179343 871229 264222450 28146 454437642 247520 481634838 59424 475430995 469594 7290822 429047 798275189 181402 986369883 80144 624470349 ...
output:
709759096
result:
ok 1 number(s): "709759096"
Test #29:
score: 0
Accepted
time: 127ms
memory: 43836kb
input:
200000 27725953 409245 579351130 307007 876558480 44101 249136023 496623 840534821 802124 204295791 629241 699493150 385126 206118437 415455 196984976 171466 123949251 168173 683245188 951731 356404194 89199 827759300 369633 68707155 861751 823471239 696213 289555624 691672 967666163 56280 112538981...
output:
812142175
result:
ok 1 number(s): "812142175"
Test #30:
score: 0
Accepted
time: 124ms
memory: 44116kb
input:
200000 910015843 701193 578421159 936484 901901822 747069 91400806 647907 688772605 106306 5840115 156280 702361794 987368 454912210 87565 379540156 675921 696751868 208222 102267924 66805 258370746 963583 878916470 455649 367016024 543508 229586239 996083 780836060 977751 538897027 999712 895574906...
output:
786140558
result:
ok 1 number(s): "786140558"
Test #31:
score: 0
Accepted
time: 124ms
memory: 44136kb
input:
200000 87273023 250038 208894968 598666 295841383 225846 933665591 864599 242043098 443193 807384439 716024 197730 781097 72302202 535482 635724263 923479 564521776 505167 521290662 247287 160337299 837966 930073640 798561 665324894 968368 972137728 295954 640712715 488021 446564379 943145 47207048 ...
output:
587406406
result:
ok 1 number(s): "587406406"
Test #32:
score: 0
Accepted
time: 131ms
memory: 43768kb
input:
200000 264530204 798882 544401485 452336 689780944 704623 144526593 15883 90280882 714671 313961471 243063 298033666 383338 321095975 983399 818279442 395229 842357102 769408 13942326 170873 693707632 679645 276198101 141473 963633763 425933 83285435 595824 131993151 774099 17795242 886577 535275681...
output:
153707858
result:
ok 1 number(s): "153707858"
Test #33:
score: 0
Accepted
time: 128ms
memory: 43900kb
input:
200000 441787385 347726 543471514 81813 10091577 407592 691824085 232575 643551376 18853 115505794 578615 300902310 209771 938485968 431316 705867330 675491 710127010 842160 432965064 318650 890641476 778220 622322563 227490 630538851 42282 825836925 862990 623273587 251666 589026106 862713 31831160...
output:
985902357
result:
ok 1 number(s): "985902357"
Test #34:
score: 0
Accepted
time: 113ms
memory: 43880kb
input:
200000 324077274 896571 878978032 711291 404031138 853665 197652380 416563 196821868 355739 917050119 138359 893705538 779309 187279740 911937 257018728 147242 577896918 139105 851987801 466428 497640737 619899 673479733 537698 928847720 467143 936984633 905965 483150242 570448 570322386 806146 8063...
output:
471261632
result:
ok 1 number(s): "471261632"
Test #35:
score: 0
Accepted
time: 131ms
memory: 43780kb
input:
200000 501334456 445415 583080768 373473 429374480 332442 744949872 600551 45059653 627218 718594443 698102 191541474 605742 436073513 584046 439573908 427504 150699534 179154 639606758 422718 399607289 494283 19604194 847906 522123880 148900 974503413 205835 974430678 80719 772957030 782282 9580123...
output:
732641677
result:
ok 1 number(s): "732641677"
Test #36:
score: 0
Accepted
time: 119ms
memory: 44048kb
input:
200000 678591637 737363 213554577 2950 823314041 35410 955810875 784539 893297438 931400 151542546 225142 825813899 175279 348430797 31963 695758015 899254 18469442 476099 763662204 570496 932977622 335962 365728656 190818 820432749 541057 85651121 505705 760678405 334093 49220601 725714 741048305 8...
output:
490172924
result:
ok 1 number(s): "490172924"
Test #37:
score: 0
Accepted
time: 130ms
memory: 44000kb
input:
200000 855848818 286208 212624606 889324 217253602 481483 798075659 968527 446567931 235582 658119579 784886 123649834 1712 597224570 479880 583345903 179516 296304767 740340 182684940 685569 834944174 434537 785482046 276835 118741618 965918 533235318 805575 620555060 844363 620451465 701851 229116...
output:
29095058
result:
ok 1 number(s): "29095058"
Test #38:
score: 0
Accepted
time: 115ms
memory: 44436kb
input:
200000 422419410 252586 156164591 756994 479248683 52021 196393930 411475 134196628 168548 931077187 643949 576748683 552498 336664638 586044 466024018 164060 736649985 795119 445710070 636514 269322110 775352 217704118 353226 886459319 703311 906771778 423069 839607664 235119 255926071 889512 72042...
output:
684095724
result:
ok 1 number(s): "684095724"
Test #39:
score: 0
Accepted
time: 34ms
memory: 36352kb
input:
200000 0 423800 0 569923 0 987699 0 428419 0 186261 0 722875 0 399409 0 413102 0 750299 0 631459 0 781805 0 211238 0 708867 0 541062 0 840511 0 102229 0 122054 0 360875 0 139328 0 133923 0 391132 0 130781 0 933322 0 752570 0 25535 0 288931 0 708020 0 58755 0 376808 0 952584 0 154650 0 650662 0 11407...
output:
1
result:
ok 1 number(s): "1"
Test #40:
score: 0
Accepted
time: 76ms
memory: 40508kb
input:
200000 0 94065 1 786615 0 291881 0 988162 0 788503 1 394984 1 679672 0 710046 0 641181 1 473138 1 124717 0 636099 0 8737 0 18628 1 783943 0 472637 0 319425 1 926794 0 724739 0 701082 1 984919 0 455025 0 461788 0 971622 0 300163 0 648870 0 787345 0 592367 1 100129 1 715670 0 426015 0 486786 0 614541 ...
output:
365873876
result:
ok 1 number(s): "365873876"
Test #41:
score: 0
Accepted
time: 109ms
memory: 43340kb
input:
200000 3 218032 6 236321 3 686248 5 614829 4 341858 0 136261 10 432802 6 281115 8 690219 1 824232 5 554184 2 188133 9 178372 0 29139 8 309170 4 688628 5 635429 9 58191 2 338937 2 372080 3 503561 1 363173 9 838070 0 396162 10 256871 4 232414 1 316355 0 519764 8 552184 3 544003 6 918520 9 93263 8 1827...
output:
970777358
result:
ok 1 number(s): "970777358"
Test #42:
score: 0
Accepted
time: 115ms
memory: 43936kb
input:
200000 4 431529 78 976293 57 767294 62 847821 76 124276 68 400534 92 485064 72 149832 11 845101 20 35552 90 553034 29 378638 40 665529 16 243704 79 213706 98 67189 74 601278 43 882963 54 677452 34 569042 95 510175 73 927783 97 427093 96 396282 64 367554 65 877864 9 804139 46 479297 94 178380 55 5029...
output:
523542485
result:
ok 1 number(s): "523542485"
Test #43:
score: 0
Accepted
time: 34ms
memory: 36236kb
input:
200000 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0...
output:
1
result:
ok 1 number(s): "1"
Test #44:
score: 0
Accepted
time: 32ms
memory: 36340kb
input:
200000 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 1 1 1...
output:
1
result:
ok 1 number(s): "1"
Test #45:
score: 0
Accepted
time: 27ms
memory: 36292kb
input:
200000 6 1 7 1 6 1 10 1 5 1 3 1 7 1 5 1 9 1 2 1 4 1 0 1 3 1 9 1 8 1 7 1 6 1 6 1 5 1 3 1 10 1 9 1 1 1 9 1 2 1 4 1 4 1 9 1 2 1 4 1 9 1 3 1 9 1 2 1 2 1 5 1 10 1 7 1 8 1 9 1 3 1 5 1 5 1 9 1 6 1 5 1 1 1 2 1 4 1 1 1 0 1 1 1 3 1 8 1 3 1 0 1 3 1 1 1 0 1 3 1 4 1 1 1 5 1 2 1 7 1 5 1 4 1 10 1 0 1 7 1 3 1 6 1 5...
output:
1
result:
ok 1 number(s): "1"
Test #46:
score: 0
Accepted
time: 39ms
memory: 36420kb
input:
200000 31 1 8 1 87 1 97 1 40 1 93 1 91 1 23 1 9 1 38 1 28 1 7 1 24 1 84 1 25 1 100 1 96 1 64 1 67 1 39 1 2 1 40 1 70 1 57 1 1 1 80 1 44 1 82 1 74 1 52 1 74 1 77 1 13 1 43 1 73 1 2 1 90 1 59 1 54 1 18 1 37 1 90 1 39 1 63 1 20 1 64 1 13 1 73 1 95 1 21 1 51 1 38 1 98 1 17 1 89 1 29 1 53 1 14 1 18 1 27 ...
output:
1
result:
ok 1 number(s): "1"
Test #47:
score: 0
Accepted
time: 29ms
memory: 36236kb
input:
200000 124528376 1 194085088 1 262007476 1 74587070 1 111704579 1 206113772 1 381219723 1 557333891 1 918216713 1 682312507 1 860543171 1 912276784 1 570886398 1 386769088 1 394298768 1 682880902 1 368815681 1 510283066 1 427791146 1 531963834 1 91072712 1 622752181 1 35567664 1 674069282 1 36827865...
output:
1
result:
ok 1 number(s): "1"
Test #48:
score: 0
Accepted
time: 36ms
memory: 36256kb
input:
200000 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 536870912 1 53687...
output:
1
result:
ok 1 number(s): "1"
Test #49:
score: 0
Accepted
time: 37ms
memory: 36304kb
input:
200000 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 536870912 524288 5368...
output:
1
result:
ok 1 number(s): "1"
Test #50:
score: 0
Accepted
time: 124ms
memory: 41472kb
input:
200000 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 536870912 590490 5368...
output:
1
result:
ok 1 number(s): "1"
Test #51:
score: 0
Accepted
time: 43ms
memory: 36320kb
input:
200000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 1000000000 1000000 10000000...
output:
1
result:
ok 1 number(s): "1"
Test #52:
score: 0
Accepted
time: 149ms
memory: 38980kb
input:
200000 61 524288 7 524288 58 524288 63 524288 75 524288 96 524288 36 524288 29 524288 66 524288 97 524288 42 524288 76 524288 43 524288 77 524288 1 524288 17 524288 70 524288 89 524288 41 524288 90 524288 37 524288 11 524288 84 524288 18 524288 61 524288 8 524288 73 524288 68 524288 54 524288 92 524...
output:
413557203
result:
ok 1 number(s): "413557203"
Test #53:
score: 0
Accepted
time: 155ms
memory: 39104kb
input:
200000 809311774 524288 812115424 524288 494433594 524288 689786257 524288 309796352 524288 217821531 524288 630534446 524288 547761123 524288 820244986 524288 913542487 524288 685442762 524288 973296463 524288 749616720 524288 470502412 524288 963294645 524288 606513507 524288 591264153 524288 9357...
output:
71048845
result:
ok 1 number(s): "71048845"
Test #54:
score: 0
Accepted
time: 104ms
memory: 39056kb
input:
200000 16 531441 74 531441 8 531441 84 531441 61 531441 95 531441 60 531441 94 531441 71 531441 78 531441 29 531441 100 531441 53 531441 86 531441 54 531441 7 531441 10 531441 86 531441 8 531441 68 531441 70 531441 34 531441 80 531441 94 531441 78 531441 86 531441 85 531441 16 531441 91 531441 55 53...
output:
63393870
result:
ok 1 number(s): "63393870"
Test #55:
score: 0
Accepted
time: 119ms
memory: 39036kb
input:
200000 91899524 531441 698183888 531441 655078519 531441 922744540 531441 828540603 531441 183489093 531441 820831558 531441 993913516 531441 505253581 531441 843007631 531441 691537400 531441 127289130 531441 26982487 531441 953358838 531441 302095198 531441 421487411 531441 755745891 531441 929516...
output:
328426887
result:
ok 1 number(s): "328426887"
Test #56:
score: 0
Accepted
time: 159ms
memory: 43328kb
input:
200000 19 889056 62 889056 63 889056 78 889056 59 889056 59 889056 94 889056 64 889056 21 889056 72 889056 41 889056 14 889056 63 889056 72 889056 82 889056 52 889056 41 889056 63 889056 90 889056 92 889056 81 889056 88 889056 60 889056 90 889056 26 889056 51 889056 41 889056 91 889056 57 889056 69 ...
output:
572891556
result:
ok 1 number(s): "572891556"
Test #57:
score: 0
Accepted
time: 175ms
memory: 43240kb
input:
200000 57580235 889056 118966059 889056 609890750 889056 949876942 889056 977401908 889056 814845197 889056 423326789 889056 519255786 889056 91091400 889056 739771133 889056 72923192 889056 294881923 889056 161976715 889056 257856162 889056 578103865 889056 50051542 889056 975655195 889056 99127150...
output:
703544380
result:
ok 1 number(s): "703544380"
Test #58:
score: 0
Accepted
time: 6ms
memory: 34852kb
input:
200 819538436 6 507992159 12 378750146 18 968660315 24 807160309 30 273926919 36 622841 42 555466951 48 316862335 54 71496607 60 570615478 66 209158681 72 387932317 78 344003569 84 754569370 90 755912339 96 758426743 102 906504611 108 75456162 114 162982631 120 237044876 126 942967202 132 193895812 ...
output:
311363016
result:
ok 1 number(s): "311363016"
Test #59:
score: 0
Accepted
time: 4ms
memory: 34760kb
input:
2000 39919403 6 2374045 12 718262677 18 37105373 24 177312603 30 200658587 36 208091136 42 463170377 48 838199567 54 518403079 60 763767261 66 976130736 72 245411964 78 247159023 84 358933841 90 96477801 96 766020830 102 152843041 108 811002529 114 179267815 120 142303246 126 886978201 132 399901044...
output:
262610466
result:
ok 1 number(s): "262610466"
Test #60:
score: 0
Accepted
time: 148ms
memory: 44852kb
input:
200000 824175840 6 488750041 12 893673855 18 438646868 24 506562578 30 184637200 36 761446161 42 4953165 48 923499503 54 652902113 60 817153029 66 230202371 72 946810300 78 303530617 84 906604390 90 328096095 96 697686565 102 540398115 108 228789229 114 425571938 120 208244496 126 326466740 132 9666...
output:
317396054
result:
ok 1 number(s): "317396054"