QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#269737#7881. Computational Complexityucup-team087#AC ✓46ms5316kbC++146.0kb2023-11-29 22:22:252023-11-29 22:22:25

Judging History

你现在查看的是最新测评结果

  • [2023-11-29 22:22:25]
  • 评测
  • 测评结果:AC
  • 用时:46ms
  • 内存:5316kb
  • [2023-11-29 22:22:25]
  • 提交

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")

////////////////////////////////////////////////////////////////////////////////
struct ModLong {
  static unsigned long long M;
  static long double INV_M;
  static void setM(unsigned long long m) { M = m; INV_M = 1.0L / M; }
  unsigned long long x;
  ModLong() : x(0ULL) {}
  ModLong(unsigned x_) : x(x_ % M) {}
  ModLong(unsigned long long x_) : x(x_ % M) {}
  ModLong(int x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
  ModLong(long long x_) : x(((x_ %= static_cast<long long>(M)) < 0) ? (x_ + static_cast<long long>(M)) : x_) {}
  ModLong &operator+=(const ModLong &a) { x = ((x += a.x) >= M) ? (x - M) : x; return *this; }
  ModLong &operator-=(const ModLong &a) { x = ((x -= a.x) >= M) ? (x + M) : x; return *this; }
  ModLong &operator*=(const ModLong &a) {
    // https://github.com/kth-competitive-programming/kactl/blob/main/doc/modmul-proof.pdf
    // This works at least for M < 2^62, assuming the usual 80-bit long double.
    const long long y = x * a.x - M * static_cast<unsigned long long>(INV_M * x * a.x);
    x = (y < 0LL) ? (y + M) : (y >= static_cast<long long>(M)) ? (y - M) : y;
    return *this;
  }
  ModLong &operator/=(const ModLong &a) { return (*this *= a.inv()); }
  ModLong pow(long long e) const {
    if (e < 0) return inv().pow(-e);
    ModLong a = *this, b = 1ULL; for (; e; e >>= 1) { if (e & 1) b *= a; a *= a; } return b;
  }
  ModLong inv() const {
    unsigned long long a = M, b = x; long long y = 0, z = 1;
    for (; b; ) { const unsigned long long q = a / b; const unsigned long long c = a - q * b; a = b; b = c; const long long w = y - static_cast<long long>(q) * z; y = z; z = w; }
    assert(a == 1ULL); return ModLong(y);
  }
  ModLong operator+() const { return *this; }
  ModLong operator-() const { ModLong a; a.x = x ? (M - x) : 0ULL; return a; }
  ModLong operator+(const ModLong &a) const { return (ModLong(*this) += a); }
  ModLong operator-(const ModLong &a) const { return (ModLong(*this) -= a); }
  ModLong operator*(const ModLong &a) const { return (ModLong(*this) *= a); }
  ModLong operator/(const ModLong &a) const { return (ModLong(*this) /= a); }
  template <class T> friend ModLong operator+(T a, const ModLong &b) { return (ModLong(a) += b); }
  template <class T> friend ModLong operator-(T a, const ModLong &b) { return (ModLong(a) -= b); }
  template <class T> friend ModLong operator*(T a, const ModLong &b) { return (ModLong(a) *= b); }
  template <class T> friend ModLong operator/(T a, const ModLong &b) { return (ModLong(a) /= b); }
  explicit operator bool() const { return x; }
  bool operator==(const ModLong &a) const { return (x == a.x); }
  bool operator!=(const ModLong &a) const { return (x != a.x); }
  friend std::ostream &operator<<(std::ostream &os, const ModLong &a) { return os << a.x; }
};
unsigned long long ModLong::M;
long double ModLong::INV_M;
// !!!Use ModLong::setM!!!
////////////////////////////////////////////////////////////////////////////////

using Mint = ModLong;


constexpr Int K = 100;
constexpr Int LIM = 1001001001001001LL;

Int F0, G0, M;
int T;
vector<Int> N;

int main() {
  for (; ~scanf("%lld%lld%d%lld", &F0, &G0, &T, &M); ) {
    N.resize(T);
    for (int t = 0; t < T; ++t) {
      scanf("%lld", &N[t]);
    }
    Mint::setM(M);
    
    vector<Int> F(K + 1), G(K + 1);
    F[0] = F0;
    G[0] = G0;
    for (Int n = 1; n <= K; ++n) {
      F[n] = max(n, G[n/2] + G[n/3] + G[n/5] + G[n/7]);
      G[n] = max(n, F[n/2] + F[n/3] + F[n/4] + F[n/5]);
    }
// cerr<<"F = "<<F<<endl;
// cerr<<"G = "<<G<<endl;
    
    vector<Int> ns;
    vector<Mint> fs, gs;
    priority_queue<Int, vector<Int>, greater<Int>> que;
    auto add = [&](Int n, Mint f, Mint g) -> void {
      ns.push_back(n);
      fs.push_back(f);
      gs.push_back(g);
      for (const Int d : {2, 3, 5, 7}) {
        que.push(d * n);
      }
    };
    auto getF = [&](Int n) -> Mint {
      const int pos = upper_bound(ns.begin(), ns.end(), n) - ns.begin() - 1;
      return fs[pos];
    };
    auto getG = [&](Int n) -> Mint {
      const int pos = upper_bound(ns.begin(), ns.end(), n) - ns.begin() - 1;
      return gs[pos];
    };
    
    for (Int n = 0; n <= K; ++n) {
      if (n == 0 || F[n - 1] != F[n] || G[n - 1] != G[n]) {
        add(n, F[n], G[n]);
      }
    }
    for (; ; ) {
      const Int n = que.top();
      que.pop();
      if (n > LIM) {
        break;
      }
      if (ns.back() < n) {
        const Mint f = getG(n/2) + getG(n/3) + getG(n/5) + getG(n/7);
        const Mint g = getF(n/2) + getF(n/3) + getF(n/4) + getF(n/5);
        add(n, f, g);
      }
    }
    
    for (int t = 0; t < T; ++t) {
      const Mint f = getF(N[t]);
      const Mint g = getG(N[t]);
      printf("%llu %llu\n", f.x, g.x);
    }
  }
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 16ms
memory: 4408kb

input:

1958 920 10 100000000000
0
1
2
3
10
100
200
1000
19580920
20232023

output:

1958 920
3680 7832
10592 9554
17504 11276
50294 64826
784112 893714
1894550 1905470
12057866 12979424
71481494756 48626708512
28127864908 7251681354

result:

ok 20 numbers

Test #2:

score: 0
Accepted
time: 16ms
memory: 4516kb

input:

0 0 10 100000000000
0
1
2
3
4
10
20
30
40
100

output:

0 0
1 1
2 2
3 3
4 4
11 12
25 26
41 41
55 58
162 172

result:

ok 20 numbers

Test #3:

score: 0
Accepted
time: 13ms
memory: 4428kb

input:

2023 2023 10 2023
0
1
2
3
4
5
6
7
8
9

output:

0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0

result:

ok 20 numbers

Test #4:

score: 0
Accepted
time: 17ms
memory: 4596kb

input:

36092 30559 2149 729566623185
909730017626
961811467628
978809456383
494310140318
760462959632
726343527430
220697276132
366336227300
456813204361
569783542145
13854148170
51526515764
564416233246
876430686824
862897449267
956440673661
512777546436
728860125927
799238602356
978766770799
47962348351
...

output:

192287632545 510282654057
513694515018 658644741565
90751152870 6088748556
138070013247 301112114677
224113421002 105290451187
630454127249 196841848259
546918129568 526274849982
226761501362 157889210040
135623074930 620463814922
78467045157 602244472172
51639549042 411354142414
329188915935 306494...

result:

ok 4298 numbers

Test #5:

score: 0
Accepted
time: 15ms
memory: 4592kb

input:

46012 72474 6895 931299293479
635558333906
151352929427
186830308154
201652909474
130684521091
862625793178
335372663856
565394770762
609752364488
636658378167
568072145317
23602174799
74849827839
567735061723
964475612065
721588322843
526921882143
141483206690
794896616456
923141155683
443983986019...

output:

737640936783 269480550026
785950579990 586907405473
274405996613 356240054012
164145774405 803378519477
613956922400 426121843045
509646717167 788278629379
95131481441 672600899832
720839818877 52329269906
131977527669 257593035330
737640936783 269480550026
202443098753 171133839273
188615102144 605...

result:

ok 13790 numbers

Test #6:

score: 0
Accepted
time: 35ms
memory: 5200kb

input:

4625 65696 87448 104757899185
324541097749
340894391228
353710640194
913290645927
500906082550
994613091630
486893604015
755863379632
795242109754
670982629049
89739557323
995677833835
622128974870
291590021762
74643709454
491030939322
504220665415
590951839890
749414110824
908656060298
831415689095...

output:

24017028596 61020984279
90036018081 8518714361
4807132724 94915889679
60642395760 99169995073
45912197521 30663794937
26807208137 73005099296
31855861883 38442189712
61377861921 69296474844
15633158436 24561226404
83188091024 101278210525
92283972576 51782451279
22904017080 27746280119
46615471334 7...

result:

ok 174896 numbers

Test #7:

score: 0
Accepted
time: 25ms
memory: 4612kb

input:

14545 18504 24898 310785536775
50369414029
493590300593
553141557375
616338447787
866832676714
135190324674
601568991739
991767475529
948181269880
701011912636
639662587174
967753492870
160818187307
982894396663
184811806844
288729173645
518365001123
3574920653
699636637896
885581030321
227437326762...

output:

230379585588 282893684496
13911364238 39284517930
176790841557 274445952454
193216065450 156787491642
209030903098 129334601749
303968485891 121048097813
281524501935 227151375068
113606190940 153251759384
52704408619 125469600129
282450949147 185742976542
283723332110 113117774598
35391811596 23685...

result:

ok 49796 numbers

Test #8:

score: 0
Accepted
time: 18ms
memory: 4624kb

input:

24465 60420 5451 512518207068
743647145169
687426729690
724316856711
323681216943
237054238172
271472590422
716244379463
186531051694
101120430005
772181715954
161329999180
939829151905
671251781902
706749356702
290684936938
58171790124
528214369534
411903034120
690999684701
866800967640
62345896443...

output:

459924162645 318783416538
339019744008 78457535841
220446603579 257208701322
484581216738 249822897402
339783439530 427811175228
16082994351 231701822103
139456487361 111068628870
409702155636 141745699002
350279528034 52998807225
34751698464 318301237488
354335881755 315047176536
293154215637 12022...

result:

ok 10902 numbers

Test #9:

score: 0
Accepted
time: 19ms
memory: 4636kb

input:

58732 77988 10197 718545844658
432629909013
876968191491
923747773891
31023986099
607275799632
403459888874
826624799890
385589595156
249764622836
797916032244
711253029031
911904810940
218530928931
398053731601
400853034329
827614406604
505513152806
824526114884
645517179069
852315872255
1518563480...

output:

24000605268 693906447722
525784005798 714879350432
36422110278 667430950574
542153388742 693441524642
362698623376 431263731428
672885760590 97526477814
391490140074 590187631066
328145721424 601650408696
195995642958 617957874512
710138473080 616425385720
122228033978 1244962196
629811143468 197577...

result:

ok 20394 numbers

Test #10:

score: 0
Accepted
time: 42ms
memory: 5000kb

input:

22238 38788 74071 415988077246
383064772058
462095580167
177796182736
526444376691
553790727170
341399532741
434214439467
93665007089
8304450603
715899864226
581669048092
416564857486
796877611087
243428789606
100626765568
394142066971
253575121111
895217901037
415120242068
471521631858
970528271113...

output:

385279906044 258911594936
22906585374 73540222996
57816276602 201337940164
7149938072 174502276630
209805777078 77501184158
57919629614 274052543450
126817027564 101901346578
112656720460 197320817058
354605200408 34739504608
46029199082 30272239080
71552593352 181566346300
377248315820 100880109630...

result:

ok 148142 numbers

Test #11:

score: 0
Accepted
time: 44ms
memory: 5152kb

input:

32158 91598 78816 622015714836
72047535902
655932009263
381522067212
229492178551
915422354038
481976765785
544594859895
288428583255
165538578025
745929147812
135887045238
388640516521
344156758116
930438197210
206499895662
163584683449
267719456819
312135949096
365342769140
457036536473
3622549414...

output:

210074081370 27113743842
259753958536 98110597916
120975103772 293399465790
194692867960 22758588982
525481257566 596282347744
425811249644 466839902174
570537420584 570043937800
99647769876 444393829062
510257855410 587819161518
106048452974 319224577026
588389038572 356369734726
379782897354 43256...

result:

ok 157632 numbers

Test #12:

score: 0
Accepted
time: 44ms
memory: 5236kb

input:

66425 33512 92074 828043352426
802170819478
845473471064
548402399253
941129915004
285643915496
613964064237
659270247619
524332679152
318477738151
817098951130
653259489949
360716175556
854590352711
658588124545
316667993052
928732332633
245018240090
724759029859
324155230804
438256473792
753981611...

output:

571418482429 265649138476
22819138341 417543158364
153077693089 319889825969
617869129685 210757061376
617468843391 631998922716
809093498986 137138398929
735211697119 537435604204
203539232394 77766921856
275785833762 548878412771
345019591447 786348488828
568177254727 496265684109
570040097867 769...

result:

ok 184148 numbers

Test #13:

score: 0
Accepted
time: 38ms
memory: 5308kb

input:

691 51080 96820 997206990835
491153583322
2464347724
747833316433
648472684160
655865476956
750246329986
778240602638
714801288022
467121930981
847128234716
207477487095
332791834591
393279565148
349892499444
426836090442
735020501548
254867608502
174227663058
315518277609
386925825971
113157697087
...

output:

534520840400 804149866061
416422164275 356680352902
118527164544 876910262044
335218355041 646898198046
437695185993 505675456869
596505848934 63460235925
82516705726 107067453402
225528016726 73298921948
828028981155 33166268024
952947397868 510632008784
55201884803 440579937584
682609210670 870671...

result:

ok 193640 numbers

Test #14:

score: 0
Accepted
time: 19ms
memory: 4540kb

input:

34958 44302 10077 198939661130
180136347165
187710842229
919008615769
351520486020
21792071118
890823563030
888621023066
913859831484
620061091108
914003070739
724849931806
309162460922
940558712179
78042426780
532709220537
500168150731
269011944209
586850743822
270035771977
368145763291
50917933475...

output:

117455035978 26967526472
60408277698 178974599612
47314240338 111633483212
59423793458 76361182032
85605332138 97494296082
111227422708 100958486682
68297381778 28861336102
21261537948 173066024272
48181048108 149796595012
21261537948 173066024272
166175502988 37344114912
84634358838 180129068832
48...

result:

ok 20154 numbers

Test #15:

score: 0
Accepted
time: 21ms
memory: 4708kb

input:

44878 86217 14823 404967298719
905964663446
377252304030
118439532949
63158222472
392013632578
22810861481
3296410788
108623407648
773000251234
944032354325
279067928952
244392567521
450992306772
801897386820
638582350631
269610767209
283156279917
995178857289
224553266345
353660667906
900906005127
...

output:

190142890449 244470971345
379354961437 325967247312
184610787308 162106693043
364791388846 289334875234
318662521945 303943107786
286847252478 240477331919
14401399636 307033127647
170574414386 16968285366
104809191045 347266983126
182417008317 324019429274
113692605610 352842749791
115787178120 100...

result:

ok 29646 numbers

Test #16:

score: 0
Accepted
time: 45ms
memory: 5288kb

input:

54798 3784 95377 606699969013
594947427289
534243180690
322165417425
766206024333
762235194037
159093127229
113676831216
307681951110
958489996500
15202157642
800735340959
212173259261
998271453803
488906794423
748750448021
71603968828
260455063188
444647490488
179070760714
334880605225
296927642794...

output:

341469520610 34297884258
483506005344 514322431985
215668302436 102971149289
251555419088 241673597650
489334646853 146087310468
373531819909 5875558730
547641314713 115445354803
56671202935 585660595313
434183614006 427069758568
507992732202 161360391575
372277565308 158501587196
2812446735 4065254...

result:

ok 190754 numbers

Test #17:

score: 0
Accepted
time: 19ms
memory: 4528kb

input:

13411 80941 8634 775863607423
288225158429
723784642491
489045749465
473548793489
132456755496
299670360274
228352218940
539291079712
111429156625
45231441228
354953338105
184248918296
508705048396
217056721758
854623578115
836751618012
270304431600
857270571252
174728774814
320395509840
69294928046...

output:

591813768009 345252306867
774832624322 516062411906
483646598686 456360015601
554819172869 606585852779
184084637780 404892563391
407842670678 108876018356
427729520752 667032104891
621563017412 344011978455
128081326303 5335046788
558222758585 221311656103
473962366871 211359652781
441486734617 248...

result:

ok 17268 numbers

Test #18:

score: 0
Accepted
time: 20ms
memory: 4696kb

input:

23331 98509 13380 977596277716
14053474709
917621071588
692771633941
180891562645
498383349659
431657658726
379873159099
734054655877
264368316752
116401244547
909171335252
156324577331
47394260833
904066129363
964791675505
601899267195
284448767307
269893652015
129246269182
264769894723
84675950833...

output:

910185445101 51127161362
309483073709 44186553740
406213576549 284612810707
764879655697 738414498537
345702121704 973343604123
194756881446 883000486544
567965265766 591270879263
744462612023 569659552265
766487460416 95980244129
8966100180 855685121221
43076283661 687193120874
409603059571 1604032...

result:

ok 26760 numbers

Test #19:

score: 0
Accepted
time: 46ms
memory: 5316kb

input:

57598 91731 93934 187918882603
698741271257
70316980952
859651965982
888234331802
868604911119
567939924474
490253579527
928818232043
417307476878
146430528133
426543779962
128400236366
557827855428
632216056698
70664805598
408187436109
261747550579
723657252510
79468796255
245989832043
476402621205...

output:

78981216711 21276778052
17544903081 53382062430
159389926345 138468916228
89632638638 30883844169
150878785672 88861009419
181183698162 66257498810
113618038957 20392334847
187340605170 118149542269
12541372092 117464380118
95683260430 116104853237
58981331583 25801943292
27220055398 13706579192
160...

result:

ok 187868 numbers

Test #20:

score: 0
Accepted
time: 35ms
memory: 5012kb

input:

52695 7123 61481 257561415005
17008684778
344147111453
266058899394
499622553739
799670854487
782519072836
712204813965
472396465724
240952868625
811339595133
414378717229
220830664187
610638161037
398079642152
267709549454
456587539747
427654757300
209077998802
883752313814
461419118044
28725487238...

output:

56944446211 145111691479
155884072482 159763011604
107598940021 177748291491
132448135045 56693782685
37469469751 248804989331
232618471610 147459497634
222740553369 2164385734
27611306775 230448848664
120860473647 31753301584
208510991573 183391132666
17110163099 216152969107
198452568703 204368802...

result:

ok 122962 numbers

Test #21:

score: 0
Accepted
time: 35ms
memory: 5048kb

input:

62616 24691 74739 426725053414
705991448622
533688573254
428644264138
206965322895
165597448649
918801338584
826880201689
667160041890
393892028751
841368878719
927456194644
192906323222
153622340771
121934602192
377877646844
262875708661
404953540571
621701079566
838269808182
405793502928
683276510...

output:

76607802624 372723679732
235870335094 302779487500
71372258483 345069678238
17260190669 250701579446
81424230334 26554092643
52073051687 240148796452
230672665374 9040201267
59069124947 306472058641
85661824391 269355848350
301128766784 219331536689
241583175097 138763175863
234575507289 25176286883...

result:

ok 149478 numbers

Test #22:

score: 0
Accepted
time: 36ms
memory: 5200kb

input:

21229 42260 79484 632752691004
394974212466
727525002351
636665115910
914308092052
535819010109
50788637036
937260622117
866218585352
579381774017
908243714741
485969159086
164981982257
664055935365
817533944388
483750776938
28023357844
419097876279
71169712765
792787302550
387013440247
75003180423
...

output:

464947901914 49723548097
488962865345 495188549088
426498780777 605876274923
99815805974 560257437244
115118402996 375057086130
237161766470 603347580963
491445604209 74399974288
12206578288 328277698765
76703615681 423622630349
362463851628 581843974926
503695970862 546310237238
415280580353 436187...

result:

ok 158968 numbers

Test #23:

score: 0
Accepted
time: 40ms
memory: 5300kb

input:

31149 95069 92742 838780328594
125097496042
880220911716
799250480655
621650861208
906040571568
187070902784
88781562275
97827713952
732320934143
942567965624
999046636501
132762673996
211335082394
541388904427
593918874329
834311526760
433242211986
483792793528
784150349355
372528344862
47102481809...

output:

282706614480 691139963495
459182927116 462862481746
837777696659 836937900037
197642913216 87781463248
350800231241 114435523510
64975317467 812451798488
222382174848 670422029763
397987176304 442231465293
428908392023 836508187639
447747955783 804202859294
676109010665 160442818033
126710396352 604...

result:

ok 185484 numbers

Test #24:

score: 0
Accepted
time: 39ms
memory: 5124kb

input:

65416 36983 73295 40512998888
814080259886
69762373516
2976365130
324698663068
271967165731
327648135828
203456949999
292591290118
885260094270
9442801645
557559600943
104838333031
717473709693
232693279326
667241419283
599459175943
443091580398
896415874292
742962811019
353748282181
867046455759
96...

output:

9469055643 23175992552
34729160193 29541944765
22339854538 27409456324
6214255563 22483867766
32973395479 32257195971
10458245291 24515876982
39538605972 2372245250
11307606684 27317784612
27047430245 36227045396
6424663047 27390254614
17871606726 12457958360
12760948377 19786401422
11371880804 2350...

result:

ok 146590 numbers

Test #25:

score: 0
Accepted
time: 41ms
memory: 5144kb

input:

75336 54552 78041 209676637298
535613608870
263598802612
206702249606
36336399520
642188727190
459635434280
318132337722
487354866284
33904287099
43767052527
74932045653
40068439630
264752856722
956548239367
768819582081
364606825125
420390363669
341589540195
697480305387
339263186797
263068093426
6...

output:

37789907636 75244761368
115148124680 126737002114
9327055772 95636760496
74945968824 53310697136
67911043428 153502097464
205681692810 149190738070
78296788998 112567063034
92649461760 166608086376
77587418680 183521878602
159563215508 139264221860
89053894592 82720338890
201602360266 100558372762
2...

result:

ok 156082 numbers

Test #26:

score: 0
Accepted
time: 40ms
memory: 5216kb

input:

9602 72120 91299 415704274887
224596372713
416294711977
373582581647
739384201381
12410288649
595917700029
432807725446
686413409745
186843447225
110641888549
629150042801
12144098665
770891484021
680403199406
878987679471
170894994040
434534699377
754212620959
651997799756
283637571680
650499796502...

output:

348431026680 347877695396
13615430445 349048622676
415550586717 165132758852
261157957834 28832211560
276375952239 25606404230
335536375687 46366315219
5914541312 172246022121
277926703017 25221190556
96273558908 376683108161
3544806502 412538694428
292544668312 257291452007
221585938772 17259307041...

result:

ok 182598 numbers

Test #27:

score: 0
Accepted
time: 41ms
memory: 5160kb

input:

43869 89689 96044 617436945181
913579136558
610131141074
573013498827
446726970537
378336882812
736494933073
543188145874
881176985911
339782607351
144966139432
183368039947
984219757701
318170631050
371707574305
989155776861
936042643224
448679035085
171130669017
639065879264
264857508999
465214341...

output:

527116618224 302925844468
409135274673 4867622508
487772334447 60782522309
474255189605 112460556602
358395917504 219756828168
574058178469 364489807585
58886203102 500040244950
417175323169 98555710277
328918498966 612088678690
400959818651 70193430469
180131980029 454076117616
155523082193 8954932...

result:

ok 192088 numbers

Test #28:

score: 0
Accepted
time: 36ms
memory: 5152kb

input:

53789 7256 76598 823464582771
643702420133
799672602875
744188798163
158364706989
748558444271
868482231525
657863533597
112786114512
529567319914
211840975454
700740484658
956295416736
865449778081
95562534344
95028906954
705485259703
421682851060
583753749781
593583373632
250372413614
442543071837...

output:

336982592279 209152989305
525278380262 582541722932
89903258111 153819198578
746581655534 190820337938
606115556009 396217805321
780620762471 352930461599
124765523297 360682494782
506602544645 342580954289
178321808096 656231856074
553760858204 125264350583
492969834686 431643323321
475637128097 73...

result:

ok 153196 numbers

Test #29:

score: 0
Accepted
time: 21ms
memory: 4624kb

input:

88056 84412 14048 25197253065
332685183977
948073544944
947914682640
824566956414
118780005730
4764497272
768243954025
307549690677
682506480040
241870259040
254958481804
924076108475
371588405378
786866909244
205197004344
507478461321
435827186768
28927415684
552395835297
231592350933
834269742209
...

output:

21008599333 24681159222
3640607646 41989894
3640607646 41989894
21379344504 24802133765
7373344316 17226401714
17186646183 4795184678
21640282868 4381644084
12666845587 21539114570
13508740350 11412138029
11872765920 22751257399
19527210946 17662614526
16733438324 10913141904
13088610254 20983672198...

result:

ok 28096 numbers

Test #30:

score: 0
Accepted
time: 30ms
memory: 5032kb

input:

47912 51112 57403 66565720879
646657630203
226198642740
317476063615
435955178351
49845949098
256189198070
27040740898
846832957064
501856904491
906779326040
201652899339
20801503591
420103743691
589576047135
402241748200
560173532254
610324328080
518643129273
356679352855
410176084499
645121993389
...

output:

49523883289 25464198765
34011117770 42110675251
34973834810 41153736113
27303116518 28783996612
161594799 44664622579
31165495838 21855715340
23775178743 22050897680
58341203846 14658858464
44513867036 22020953016
61354801025 51368168040
28762773068 41169410012
38206488441 12657277718
26560997867 32...

result:

ok 114806 numbers

Test #31:

score: 0
Accepted
time: 27ms
memory: 4848kb

input:

20401 20396 37957 20401
268286484783
335640394046
420035071837
516906980796
143297947507
415772543262
392471463819
141716128622
45891500524
654796064617
936808609626
760165863782
992877162627
930537338286
276585454738
508114878295
357871766577
583328144056
931266210036
311196847223
395690989114
4114...

output:

17469 17827
1787 14493
16127 12571
16080 19662
14234 4981
14949 6699
9323 239
665 15302
19815 694
14251 9073
15998 15544
20175 14858
17736 4745
4836 3757
6770 3701
1358 9572
12453 19042
2251 1452
4836 3757
11245 16093
1824 6534
6808 2995
11936 9078
14170 17041
2690 18427
4678 194
19301 4912
13628 20...

result:

ok 75914 numbers

Test #32:

score: 0
Accepted
time: 38ms
memory: 5120kb

input:

24202 24198 75406 24202
474310106148
24623157890
609576533638
683787312836
850640716664
785994104721
528753729567
252096549050
240655076690
807735224743
7978412943
273243341196
964952821662
477816485315
9030349369
618282975685
127314383056
597472479763
380734843235
265714341591
376910926434
43287030...

output:

17560 20484
15118 2856
9478 20238
19854 7088
23742 13328
1022 4662
17028 12562
11602 798
1856 18378
8218 3706
8598 14066
20540 4162
16656 22296
15048 8474
18914 13578
428 18878
23028 14178
17454 6808
5572 2932
9700 22976
746 10008
212 24080
8350 22198
9566 3742
7894 8646
5770 4304
19316 5730
19584 1...

result:

ok 150812 numbers

Test #33:

score: 0
Accepted
time: 33ms
memory: 4904kb

input:

61007 61005 55960 61007
639193207782
750451474170
762272443002
887513197312
557983485820
151920698883
665035995315
366771936773
439713620152
956379417573
38007696530
831756305639
937028480698
20800665049
696039756974
724156105779
892462032240
611616815471
793357923999
220231835960
325580278613
82459...

output:

22725 43114
423 52454
2108 1325
5459 59444
4670 34309
36808 51626
45342 26163
33730 49340
2183 11417
13448 24181
15251 34027
6622 23893
54904 34550
30780 43809
33027 17386
26195 22854
50250 47029
59343 10294
21054 474
8293 21974
38620 55469
47596 26856
17030 34278
43592 36484
59895 59605
35450 14243...

result:

ok 111920 numbers

Test #34:

score: 0
Accepted
time: 32ms
memory: 4920kb

input:

81310 81310 60706 81310
849511796444
443729205310
956108872099
91239081788
261031287680
522142260343
801318261063
481447324497
671322748753
146164130135
109177499848
349128750349
909104139733
531234259643
419894717013
834324203169
698750201155
584620631447
201686037465
211594882764
306800215932
2206...

output:

0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
...

result:

ok 121412 numbers

Test #35:

score: 0
Accepted
time: 28ms
memory: 4740kb

input:

1632 1630 41259 1632
51240450512
132711969153
141355366603
253824446532
972669024133
892363821802
937600526812
591827744924
866086324919
299103290261
143501750730
903346747496
844334246332
74218439377
111199091912
944492300559
468192817633
598764967154
655449637961
161817409836
288020153251
61664024...

output:

824 662
1076 148
416 190
1196 782
188 506
1026 592
1094 1014
300 786
318 48
324 1412
1232 1266
1558 1292
756 110
758 1162
650 464
1022 100
646 390
1436 734
838 158
1096 750
896 518
1248 152
286 1124
92 1044
1164 1328
1446 1218
1586 1344
528 210
418 898
1090 664
720 1080
1086 1170
1204 902
912 1498
5...

result:

ok 82518 numbers

Test #36:

score: 0
Accepted
time: 37ms
memory: 5172kb

input:

4 5 78709 257277612646
858540285434
298346243264
461845298304
675716825993
258290415965
69587825263
710798099944
65144868380
447747483091
206081619456
425014159502
812114938071
584652033971
835054051952
46070463356
270186019252
608614335566
68072718724
120629871501
273535057866
12661884802
185330935...

output:

150955089168 80504734817
253272127936 212743445176
15022271083 49746416054
241081623345 184917188234
60641903687 257025353850
38059574848 154612695540
197744569448 77283252739
106569857908 232710995573
224747051313 219874491627
59036280169 186518116732
163053328425 119683022512
21253058229 533539829...

result:

ok 157418 numbers

Test #37:

score: 0
Accepted
time: 45ms
memory: 5256kb

input:

3 5 91967 459010282939
547523049278
487887705065
624430663049
383059595149
628511977424
210165058307
858024072808
259908444545
604981610513
240405870339
974937189353
784190597106
131931181000
563203979288
156238560746
39628635731
585913118837
480695799488
75147365869
254754995186
404388555174
680204...

output:

65439028898 337256423985
306823953138 369800942135
222675285699 442905157025
454704974194 62923470470
144941136570 365134209530
444489864950 164369567175
70084285972 97616554850
316595650356 78437837965
262645034460 382115681234
426673821577 93491078720
137993439742 445814787945
294751138829 2623525...

result:

ok 183934 numbers

Test #38:

score: 0
Accepted
time: 31ms
memory: 5104kb

input:

1 0 72520 628173921349
273351365557
677429166865
828156547525
94697331601
998733538884
346447324055
972699460531
458966988007
757920770640
270435153925
533450153795
756266256141
638069808299
250213386891
262111690840
804776284915
600057454545
930164432687
66510412673
203424347365
800410192842
207627...

output:

188130335352 300949694663
235195349322 482107267740
7387396434 331791894109
484230685142 604302256041
583789564504 162186354181
191388863458 510333136599
268821070992 223536558201
74842734196 549164802590
321610112487 412143998521
74173897319 159549767872
323796273390 439190763472
321384476133 41193...

result:

ok 145040 numbers

Test #39:

score: 0
Accepted
time: 19ms
memory: 4524kb

input:

1 4 9970 834201558939
966629096698
834420043526
995036879565
797745133462
364660133046
478434622508
87374848254
686281149313
906564963470
341604957243
46527631209
728341915176
185348955328
982658281523
372279788230
611064453829
614201790252
338492546154
21027907041
184644284684
155291310777
70250083...

output:

582432505198 190025258494
528898797685 465711371740
164694352939 370214689786
81819234886 787716669583
484215887266 256172978164
786992653855 272321485921
27308630911 513881583067
265652938000 689103301924
261782941492 692156578858
208832437942 342720977203
344226458191 90145939771
307423268977 3478...

result:

ok 19940 numbers

Test #40:

score: 0
Accepted
time: 22ms
memory: 4632kb

input:

5 0 20621 908139058636
276306575626
112545141323
401443812977
409133355400
300021043710
693013770870
305031115396
225564415698
767055907653
969668471807
34362568477
820772342997
238159260938
744226899682
569324532087
655169590170
747558411833
828208259743
788465872165
363228018250
2989114392
2127851...

output:

578763986101 135427045682
49664424537 367746168902
585741105918 448909077212
737651723038 82421877963
54199850264 1574588660
582550804069 18835986137
321462492009 602241649144
631503514614 626284288136
668109794982 528377986849
428608846358 134185737782
143972828873 190957684033
523056073334 8198656...

result:

ok 41242 numbers

Extra Test:

score: 0
Extra Test Passed