QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#580680#8961. Wide Expressionfractal#AC ✓676ms86348kbC++172.4kb2024-09-21 23:06:572024-09-21 23:06:59

Judging History

This is the latest submission verdict.

  • [2024-09-21 23:06:59]
  • Judged
  • Verdict: AC
  • Time: 676ms
  • Memory: 86348kb
  • [2024-09-21 23:06:57]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod = (119 << 23) + 1, root = 62;
ll modpow(ll b, ll e) {
    ll ans = 1;
    for (; e; b = b * b % mod, e /= 2)
        if (e & 1) ans = ans * b % mod;
    return ans;
}

typedef vector<ll> vl;

void ntt(vl &a) {
    int n = sz(a), L = 31 - __builtin_clz(n);
    static vl rt(2, 1);
    for (static int k = 2, s = 2; k < n; k *= 2, s++) {
        rt.resize(n);
        ll z[] = {1, modpow(root, mod>>s)};
        rep(i, k, 2*k) rt[i] = rt[i/2]*z[i&1]%mod;
    }
    vi rev(n);
    rep(i,0,n) rev[i] = (rev[i/2]|(i&1)<<L) / 2;
    rep(i,0,n) if(i<rev[i]) swap(a[i], a[rev[i]]);
    for(int k = 1; k < n; k *= 2) {
        for (int i = 0; i < n; i += 2 * k) rep(j, 0, k) {
            ll z = rt[j + k] * a[i + j + k] % mod, &ai = a[i + j];
            a[i + j + k] = ai - z + (z > ai ? mod : 0);
            ai += (ai + z >= mod ? z - mod : z);
        }
    }
}

vl conv(const vl &a, const vl &b) {
    if (a.empty() || b.empty()) return {};
    int s = sz(a) + sz(b) - 1, B = 32 - __builtin_clz(s), n = 1<<B;
    int inv = modpow(n, mod-2);
    vl L(a), R(b), out(n);
    L.resize(n), R.resize(n);
    ntt(L), ntt(R);
    rep(i, 0, n)
        out[-i & (n - 1)] = (ll)L[i] * R[i] % mod * inv % mod;
    ntt(out);
    return {out.begin(), out.begin() + s};
}

int pw[90000*2+2][101];

void solve() {
    int n, m, k, l;
    cin >> n >> m >> k >> l;
    vl a(n * n + 1), b(m * m + 1);
    for (int i = 0; i <= n; ++i) for (int j = 0; j <= n; ++j) a[i * j]++;
    for (int i = 0; i <= m; ++i) for (int j = 0; j <= m; ++j) b[i * j]++;
    vl c = conv(a, b);
    int ans = 0;
    for (int i = 0; i <= n * n + m * m; ++i) {
        for (int x = 0; x <= k; ++x) {
            for (int y = 0; y <= l; ++y) {
                int p = x ^ y;
                ans = (ans + (pw[i + 1][p] * c[i] % mod)) % mod;
            }
        }
    }
    cout << ans << '\n';
}


int main() {
    cin.tie(0)->sync_with_stdio(0);
    int T;
    cin >> T;
    for (int i = 0; i <= 90000*2 + 1;++i) {
        pw[i][0] = 1;
        for (int j = 1; j <= 100; ++j) {
            pw[i][j] = pw[i][j - 1] * 1ll * i % mod;
        }
    }
    while(T--)solve();

}

詳細信息

Test #1:

score: 100
Accepted
time: 83ms
memory: 75572kb

input:

6
0 0 0 0
0 0 3 6
1 0 1 0
1 1 1 1
25 2 20 23
99 82 44 3

output:

1
28
9
80
950955110
140425437

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 309ms
memory: 75140kb

input:

67
0 0 0 1
1 1 1 2
2 2 2 3
3 3 3 4
4 4 4 5
5 5 5 6
6 6 6 7
7 7 7 8
8 8 8 9
9 9 9 10
10 10 10 11
11 11 11 12
12 12 12 13
13 13 13 14
14 14 14 15
15 15 15 16
16 16 16 17
17 17 17 18
18 18 18 19
19 19 19 20
20 20 20 21
21 21 21 22
22 22 22 23
23 23 23 24
24 24 24 25
25 25 25 26
26 26 26 27
27 27 27 28
...

output:

2
206
19656
503282237
948035747
615042068
549667775
579898364
264361024
127978110
919126419
224375477
4278427
779010735
532723399
426219373
937219252
176223448
147952450
679769535
18798507
478221477
813486085
298882841
661960440
756312728
877512920
758491947
974035931
163904411
816740871
889471693
8...

result:

ok 67 numbers

Test #3:

score: 0
Accepted
time: 568ms
memory: 86248kb

input:

1
300 300 42 16

output:

246236486

result:

ok 1 number(s): "246236486"

Test #4:

score: 0
Accepted
time: 676ms
memory: 86292kb

input:

1
300 300 22 39

output:

479259751

result:

ok 1 number(s): "479259751"

Test #5:

score: 0
Accepted
time: 246ms
memory: 86248kb

input:

1
300 300 5 42

output:

768424503

result:

ok 1 number(s): "768424503"

Test #6:

score: 0
Accepted
time: 333ms
memory: 86196kb

input:

1
300 300 41 8

output:

165915778

result:

ok 1 number(s): "165915778"

Test #7:

score: 0
Accepted
time: 367ms
memory: 86348kb

input:

1
300 300 15 27

output:

12577862

result:

ok 1 number(s): "12577862"

Test #8:

score: 0
Accepted
time: 107ms
memory: 86212kb

input:

1
300 300 0 4

output:

885590814

result:

ok 1 number(s): "885590814"

Test #9:

score: 0
Accepted
time: 90ms
memory: 86292kb

input:

1
300 300 0 0

output:

222586377

result:

ok 1 number(s): "222586377"

Test #10:

score: 0
Accepted
time: 517ms
memory: 85896kb

input:

1
299 285 23 28

output:

159110280

result:

ok 1 number(s): "159110280"

Test #11:

score: 0
Accepted
time: 412ms
memory: 85884kb

input:

1
294 287 42 12

output:

914234223

result:

ok 1 number(s): "914234223"

Test #12:

score: 0
Accepted
time: 532ms
memory: 85928kb

input:

1
297 281 20 36

output:

640964431

result:

ok 1 number(s): "640964431"

Test #13:

score: 0
Accepted
time: 426ms
memory: 85840kb

input:

1
288 289 30 17

output:

546582090

result:

ok 1 number(s): "546582090"

Test #14:

score: 0
Accepted
time: 234ms
memory: 85952kb

input:

1
281 289 5 40

output:

110097937

result:

ok 1 number(s): "110097937"

Test #15:

score: 0
Accepted
time: 173ms
memory: 84312kb

input:

1
261 251 14 12

output:

308311288

result:

ok 1 number(s): "308311288"

Test #16:

score: 0
Accepted
time: 465ms
memory: 79944kb

input:

2
125 263 3 39
122 287 38 23

output:

950531971
505101362

result:

ok 2 number(s): "950531971 505101362"

Test #17:

score: 0
Accepted
time: 195ms
memory: 77320kb

input:

3
165 185 9 16
154 159 3 38
162 179 6 33

output:

251598857
656039412
926927532

result:

ok 3 number(s): "251598857 656039412 926927532"

Test #18:

score: 0
Accepted
time: 431ms
memory: 80296kb

input:

2
286 107 21 31
256 130 10 35

output:

447158698
658654113

result:

ok 2 number(s): "447158698 658654113"

Test #19:

score: 0
Accepted
time: 160ms
memory: 80100kb

input:

2
52 287 24 2
43 271 14 10

output:

489249822
216931268

result:

ok 2 number(s): "489249822 216931268"

Test #20:

score: 0
Accepted
time: 403ms
memory: 77536kb

input:

4
83 151 37 17
63 243 18 37
92 231 32 8
91 166 5 8

output:

101029463
36629066
76022855
716631569

result:

ok 4 number(s): "101029463 36629066 76022855 716631569"

Test #21:

score: 0
Accepted
time: 220ms
memory: 77280kb

input:

6
124 108 1 7
102 130 14 4
144 139 25 2
131 102 10 41
135 110 43 1
114 102 34 19

output:

425352582
575986007
290954339
855338682
862299411
677642116

result:

ok 6 numbers

Test #22:

score: 0
Accepted
time: 230ms
memory: 77276kb

input:

4
158 72 19 27
212 60 1 16
172 83 19 17
169 79 26 8

output:

356753687
406619659
929808611
95938871

result:

ok 4 number(s): "356753687 406619659 929808611 95938871"

Test #23:

score: 0
Accepted
time: 182ms
memory: 79332kb

input:

2
265 32 8 37
256 33 5 7

output:

847802432
557956046

result:

ok 2 number(s): "847802432 557956046"

Test #24:

score: 0
Accepted
time: 297ms
memory: 77688kb

input:

2
2 252 38 11
6 252 43 11

output:

507149569
18714539

result:

ok 2 number(s): "507149569 18714539"

Test #25:

score: 0
Accepted
time: 147ms
memory: 77692kb

input:

4
13 247 5 37
15 152 4 10
10 248 1 5
17 221 3 0

output:

866196565
285534111
434412005
157035481

result:

ok 4 number(s): "866196565 285534111 434412005 157035481"

Test #26:

score: 0
Accepted
time: 372ms
memory: 75968kb

input:

11
32 109 16 32
49 118 14 35
31 125 17 38
43 122 34 10
54 144 1 7
33 110 18 18
37 110 37 12
58 120 14 7
49 110 2 7
41 125 18 34
33 135 29 34

output:

780608153
541641452
704704555
554428187
849814299
211092354
117004013
914850311
168397476
987508310
198309349

result:

ok 11 numbers

Test #27:

score: 0
Accepted
time: 235ms
memory: 75228kb

input:

17
71 96 2 34
87 62 3 8
66 61 22 3
65 74 5 36
64 85 37 15
88 79 3 41
63 76 23 6
72 89 27 12
64 78 18 35
69 71 36 5
70 83 43 2
61 93 12 10
65 97 0 26
66 83 23 20
65 64 26 1
84 78 9 7
78 89 8 7

output:

998231408
404945710
786461583
647061407
527386955
563413833
916456627
57348403
39153259
823790823
219960770
218130249
384045115
890879795
909730166
14111811
200700350

result:

ok 17 numbers

Test #28:

score: 0
Accepted
time: 389ms
memory: 75580kb

input:

11
131 32 26 24
131 59 9 8
137 34 6 5
108 38 13 22
121 43 5 10
124 44 32 27
113 36 36 25
138 59 22 37
104 34 28 31
140 52 20 3
115 50 0 10

output:

79172259
556929566
188594446
23994377
83936430
200989079
466898359
663688422
977156801
524493480
879918543

result:

ok 11 numbers

Test #29:

score: 0
Accepted
time: 578ms
memory: 77716kb

input:

5
188 11 43 13
169 10 25 30
219 14 31 28
162 15 22 26
196 19 35 22

output:

641454785
372207282
888142719
801878819
125246991

result:

ok 5 number(s): "641454785 372207282 888142719 801878819 125246991"

Test #30:

score: 0
Accepted
time: 257ms
memory: 77156kb

input:

2
254 6 10 14
251 0 19 30

output:

91552697
621793228

result:

ok 2 number(s): "91552697 621793228"

Test #31:

score: 0
Accepted
time: 200ms
memory: 76952kb

input:

6
0 165 12 2
0 172 41 0
0 180 10 6
0 169 2 14
0 198 37 12
0 188 6 35

output:

986528856
687653481
534277611
68632737
674838249
670169886

result:

ok 6 numbers

Test #32:

score: 0
Accepted
time: 296ms
memory: 75860kb

input:

13
3 130 3 18
6 119 0 11
6 144 20 14
5 146 39 13
0 139 10 39
8 104 0 0
1 110 28 27
3 117 43 8
8 111 2 4
8 121 18 1
3 132 15 34
0 105 10 11
1 102 4 9

output:

219931489
7218943
821627717
409041050
371813534
893025
955488056
61295126
488039552
286845128
756805610
858362412
448295893

result:

ok 13 numbers

Test #33:

score: 0
Accepted
time: 266ms
memory: 75208kb

input:

31
24 69 0 13
10 73 18 41
22 91 17 33
10 91 7 5
10 72 42 16
13 85 20 7
21 71 4 3
17 61 14 4
16 84 21 7
13 66 2 21
19 85 35 26
21 84 17 4
25 80 16 6
20 74 2 10
13 61 19 27
24 71 14 37
24 82 8 11
24 66 14 2
16 87 43 9
19 61 30 30
15 86 0 44
13 60 5 6
14 98 5 7
21 92 14 18
24 75 17 10
15 91 4 5
18 69 1...

output:

452867449
644005874
185173750
946195332
538255879
142351738
997475766
311305336
299450511
899545955
219987611
162926134
810240866
283824540
723918616
670143524
786225695
914174768
874127890
223036455
378160365
230085421
414065715
471966859
9788012
231673610
484154227
523965706
624021404
610954604
98...

result:

ok 31 numbers

Test #34:

score: 0
Accepted
time: 372ms
memory: 74692kb

input:

53
40 46 10 9
34 42 41 2
40 32 25 18
46 47 43 7
55 58 2 2
43 38 16 28
32 39 28 35
42 35 32 30
38 43 27 3
34 32 4 3
58 31 4 39
49 45 18 25
30 55 41 13
47 38 23 22
35 55 10 35
46 40 4 3
57 36 24 26
43 46 7 19
58 48 7 30
36 54 38 13
32 38 14 16
36 34 20 32
40 41 25 27
37 31 0 16
56 36 16 7
36 53 5 10
3...

output:

792926944
41071072
309652131
77118331
165939291
790426830
483144089
533222559
598131668
922928384
724452650
812653023
602549226
805657913
36774534
646988153
294631190
916790061
342317330
57397626
201152338
98803374
489502051
493889423
202559414
103813241
937803034
17527644
838934610
796059303
854538...

result:

ok 53 numbers

Test #35:

score: 0
Accepted
time: 392ms
memory: 74976kb

input:

31
67 10 40 15
94 21 33 25
61 26 17 41
63 19 12 15
72 11 43 9
85 26 38 6
78 24 9 1
71 11 23 37
84 11 19 9
75 19 31 23
60 10 15 6
83 21 24 0
71 14 41 11
65 22 6 1
70 15 0 40
85 28 38 1
75 13 34 14
64 19 40 20
89 13 28 28
81 21 14 28
89 17 20 39
99 13 19 20
93 18 38 18
95 25 2 5
65 17 4 7
72 11 0 33
6...

output:

159996857
465525403
760305497
442965133
777097633
961223731
118782754
480054928
191343802
841245964
85669679
884689945
854959824
923778276
564065019
454551219
481243412
127585560
118019413
301813518
542609756
937744072
386165278
725397049
544299596
436198828
566251633
75133965
756420414
468841473
51...

result:

ok 31 numbers

Test #36:

score: 0
Accepted
time: 453ms
memory: 75968kb

input:

10
149 0 42 11
113 3 32 7
139 1 13 39
130 0 24 37
111 0 15 36
148 0 18 39
139 0 5 11
142 3 37 24
136 0 13 27
127 7 36 19

output:

158208021
114854383
782591995
747033752
40119804
206469137
5681410
298732836
544046233
47399350

result:

ok 10 numbers

Test #37:

score: 0
Accepted
time: 341ms
memory: 77224kb

input:

4
247 0 7 41
154 0 34 18
219 0 22 17
240 0 7 34

output:

268298685
131037620
604213153
394205620

result:

ok 4 number(s): "268298685 131037620 604213153 394205620"

Test #38:

score: 0
Accepted
time: 291ms
memory: 75000kb

input:

31
0 81 23 15
0 71 10 4
0 68 6 7
0 76 0 10
0 75 15 8
0 85 9 15
0 96 0 24
0 97 0 1
0 73 2 19
0 88 3 1
0 77 0 16
0 82 21 4
0 76 3 36
0 69 28 30
0 70 32 29
0 71 26 5
0 64 11 9
0 81 12 40
0 97 43 13
0 74 28 19
0 86 12 40
0 98 18 8
0 86 3 7
0 82 15 7
0 77 22 1
0 68 6 7
0 60 36 18
0 60 26 36
0 77 20 37
0 ...

output:

199905916
693903374
46460979
759819059
862700950
922013654
724512776
22610217
148322063
53049001
651088262
973102509
773423125
792964244
629921325
431844876
754818803
961285687
561855629
785670242
499001897
684661356
468938747
904403314
170342538
46460979
60102673
86718522
694392300
216712657
918167...

result:

ok 31 numbers

Test #39:

score: 0
Accepted
time: 320ms
memory: 74772kb

input:

100
5 31 14 2
4 41 20 36
2 35 27 2
2 40 0 12
0 34 28 25
1 54 15 42
1 40 20 22
3 33 44 7
0 56 8 22
1 30 7 1
7 36 36 24
9 58 39 20
4 48 29 34
7 54 15 0
1 42 15 1
5 47 2 43
0 43 4 14
5 48 17 0
9 51 3 15
0 41 38 11
3 31 35 12
1 35 10 38
3 35 12 12
1 37 24 20
6 55 12 7
0 38 13 39
1 38 12 32
3 33 37 6
3 3...

output:

948178226
668636055
879884157
293318731
316888165
246646421
910723017
571644155
918833628
109272308
531328242
740879220
705787415
715266482
251913462
405707702
843372939
958831648
153654011
896024305
610552115
969151747
322691622
487735020
287346439
133519758
551470463
845964674
58322565
747637165
1...

result:

ok 100 numbers

Test #40:

score: 0
Accepted
time: 174ms
memory: 74672kb

input:

100
16 14 43 7
17 29 43 3
14 24 34 0
24 23 2 1
27 16 0 5
28 11 3 18
13 23 9 13
17 11 20 37
15 16 27 28
29 11 26 7
13 29 32 10
14 26 4 3
17 14 6 12
24 18 34 8
10 17 38 2
15 19 32 27
15 10 5 19
16 19 8 8
10 13 15 6
11 13 26 15
13 18 0 36
12 12 7 10
16 28 1 7
19 10 14 16
15 19 12 3
13 10 12 3
29 23 20 ...

output:

329112876
42708580
898692370
475564646
685301009
223006203
673793627
991563680
226299690
796316998
663403651
212579246
602161916
475596785
949278683
603931133
380273419
922755853
829761127
2372391
100431997
560419454
497016559
134759410
698937469
678073151
123454414
991238460
536896195
730229665
788...

result:

ok 100 numbers

Test #41:

score: 0
Accepted
time: 338ms
memory: 74720kb

input:

97
43 0 36 1
45 0 12 1
37 3 30 33
52 0 5 16
52 5 12 38
45 0 9 14
46 1 23 11
49 0 10 1
39 2 38 21
39 0 13 9
58 2 22 38
43 0 9 43
55 6 36 24
31 0 28 25
43 0 41 15
33 6 6 9
55 0 13 5
39 3 20 0
57 2 5 42
46 2 24 33
39 4 28 4
35 2 26 2
30 7 35 7
34 1 25 32
37 1 18 6
54 2 44 8
36 0 16 21
30 4 4 41
55 3 28...

output:

773694461
598710029
481769504
883903444
466705933
676804378
571984822
756386202
250992916
326523439
517811108
820447848
666390856
585686205
732140057
890375160
812689896
464025825
456206926
382754513
394759438
983930908
490357539
91026169
407964177
694663116
324838139
120538247
461649127
298667777
1...

result:

ok 97 numbers

Test #42:

score: 0
Accepted
time: 349ms
memory: 75116kb

input:

30
93 0 11 5
99 0 26 11
73 0 17 35
69 0 1 12
68 0 43 5
79 0 38 10
76 0 0 4
98 0 17 14
61 0 13 13
89 0 31 18
67 0 34 24
77 0 27 10
64 0 16 38
91 0 21 0
85 0 33 17
84 0 23 22
90 0 24 28
91 0 30 28
69 0 9 24
77 0 42 2
87 0 4 7
67 0 1 21
77 0 5 13
79 0 17 24
83 0 10 30
80 0 18 35
80 0 13 31
90 0 6 28
80...

output:

961222425
715973426
152900850
138114738
580170803
296176344
881922512
364945322
184449904
294690896
849627132
860602152
678140860
859541591
454500229
398487135
539631697
113352798
97866976
168190286
17409866
705612837
236129421
748438388
931741130
570517366
38572632
443440603
857961071
305114471

result:

ok 30 numbers

Test #43:

score: 0
Accepted
time: 113ms
memory: 74672kb

input:

100
0 17 4 41
0 23 6 10
0 17 5 16
0 29 17 1
0 20 21 19
0 10 39 20
0 20 7 43
0 17 8 31
0 10 24 33
0 10 34 4
0 10 15 24
0 11 21 39
0 18 44 8
0 24 32 16
0 12 43 3
0 29 21 12
0 14 23 12
0 16 19 12
0 22 40 2
0 28 18 1
0 28 37 14
0 14 4 22
0 13 41 17
0 19 2 7
0 17 9 1
0 16 18 13
0 24 33 8
0 16 8 11
0 23 2...

output:

689178230
343109227
817435105
508862745
610796023
133054286
735152711
284581827
212410082
612235775
342745617
88946136
499186430
660850260
815644864
889010196
239751301
936356522
693981477
66232068
601555766
676899110
521422617
196231131
466515320
658680570
470046112
126380394
894036882
382103021
67...

result:

ok 100 numbers

Test #44:

score: 0
Accepted
time: 72ms
memory: 74852kb

input:

100
3 4 36 22
0 8 43 13
2 0 22 11
1 1 17 39
2 2 27 3
0 0 21 3
0 0 13 6
0 0 12 30
3 1 34 29
1 1 0 38
3 0 9 12
2 0 30 5
2 0 19 4
3 4 9 44
1 0 7 26
0 3 9 42
5 0 29 26
9 6 44 8
1 0 23 37
4 2 7 34
0 4 37 11
6 0 39 17
5 2 26 25
6 0 32 25
1 2 15 23
0 4 20 20
0 9 26 35
3 1 37 23
0 2 13 6
0 1 12 39
7 0 39 3
...

output:

775980391
515044195
704969849
127619332
861772240
88
98
403
940366780
565380361
600194460
553762368
433061252
49520794
989856372
467748410
988491726
751171583
825187890
544136279
176588565
86167329
353307028
724115258
612230949
126784236
237594579
939224039
288359570
929723860
264151618
752910255
13...

result:

ok 100 numbers

Test #45:

score: 0
Accepted
time: 116ms
memory: 74616kb

input:

100
24 0 18 40
13 0 15 36
20 0 23 38
15 0 21 15
14 0 23 3
28 0 25 19
10 0 19 19
11 0 40 10
18 0 13 10
22 0 29 26
10 0 29 16
11 0 6 2
28 0 9 43
11 0 16 13
25 0 4 16
15 0 35 0
18 0 29 32
18 0 1 25
13 0 17 16
10 0 39 13
13 0 15 32
28 0 20 26
10 0 7 41
18 0 13 9
21 0 0 19
13 0 37 24
15 0 22 32
23 0 33 2...

output:

251163382
897109271
467942488
151651496
316010839
210102562
529874116
713672811
13072931
452685844
176027367
927547100
176683510
699432096
88170243
528436195
186549117
550429041
657243991
18976934
114859123
130203922
514554198
26069022
249085068
868856099
80562568
811306288
18086155
338320771
431763...

result:

ok 100 numbers

Test #46:

score: 0
Accepted
time: 76ms
memory: 74636kb

input:

100
0 0 32 1
0 0 6 44
0 0 10 26
0 0 9 37
0 0 5 7
0 0 9 10
0 0 15 41
0 0 26 31
0 0 7 16
0 0 36 6
0 0 32 29
0 0 2 7
0 0 17 5
0 0 16 14
0 0 25 1
0 0 10 36
0 0 25 4
0 0 20 2
0 0 29 12
0 0 9 13
0 0 24 19
0 0 27 35
0 0 12 41
0 0 11 36
0 0 7 35
0 0 8 34
0 0 27 35
0 0 2 0
0 0 1 1
0 0 25 37
0 0 8 37
0 0 5 4
...

output:

66
315
297
380
48
110
672
864
136
259
990
24
108
255
52
407
130
63
390
140
500
1008
546
444
288
315
1008
3
4
988
342
30
315
585
646
208
962
924
783
21
408
65
48
504
540
81
775
380
84
608
645
962
63
533
42
540
396
9
950
72
696
64
90
864
63
640
595
1023
88
315
124
252
42
570
133
266
360
80
990
33
800
...

result:

ok 100 numbers

Test #47:

score: 0
Accepted
time: 401ms
memory: 80292kb

input:

100
1 0 35 17
0 0 18 12
5 5 5 5
0 0 31 24
0 2 41 15
2 2 43 5
0 3 15 32
0 6 17 10
3 0 2 8
1 0 3 42
0 21 20 40
4 6 14 6
16 4 40 18
2 3 35 27
12 1 18 4
0 0 13 42
1 4 6 44
12 0 29 25
0 0 8 38
0 0 14 42
0 0 16 7
0 3 41 14
0 0 1 17
1 86 17 10
23 9 43 5
2 0 25 36
5 0 30 8
1 0 8 16
0 0 1 32
1 0 11 3
0 0 0 2...

output:

795721254
247
891353946
800
734971233
991405518
16626552
544798896
831076501
822030126
269171801
28053719
246485805
225842721
636343520
602
503641081
270291600
351
645
136
499449152
36
326465397
729828262
155045360
882564547
34079170
66
16524
24
57908994
390977800
629802199
975017263
44
35651844
577...

result:

ok 100 numbers

Test #48:

score: 0
Accepted
time: 262ms
memory: 77432kb

input:

100
3 2 12 13
1 3 2 2
0 0 9 36
0 0 4 16
1 0 29 33
0 0 4 20
0 0 11 16
0 0 14 20
0 0 43 7
9 0 0 6
0 7 6 43
5 8 15 37
3 0 24 11
8 2 1 11
0 2 35 19
1 5 33 25
5 7 19 7
253 27 5 27
0 28 26 29
6 0 22 32
0 0 11 4
34 0 4 5
3 0 1 43
0 0 19 14
3 0 2 23
0 9 9 3
43 73 5 7
0 3 1 1
0 0 17 39
13 0 43 5
0 3 30 31
10...

output:

697871525
21264
370
85
935790913
105
204
315
352
422154746
364647024
158099258
390449220
948099517
372111027
93821377
895357619
86782098
470434815
268230182
60
57089449
542574817
300
488030309
571079249
524602079
136
720
860415238
610580907
11063560
946271041
46
444363794
288359570
931968052
3228761...

result:

ok 100 numbers

Test #49:

score: 0
Accepted
time: 359ms
memory: 79404kb

input:

100
5 0 19 17
30 0 31 21
283 10 21 16
0 0 10 1
0 4 27 35
0 1 3 38
1 5 2 44
0 0 9 40
0 0 38 5
4 6 40 4
15 2 20 17
201 41 42 6
0 27 16 8
0 0 27 31
4 0 21 7
0 0 12 10
0 0 43 2
32 0 5 25
25 19 2 44
21 0 9 26
0 0 8 0
0 0 19 18
1 0 16 10
11 0 6 44
0 0 15 5
0 6 31 27
0 3 31 12
0 1 14 32
2 2 1 5
8 12 24 30
...

output:

225957405
914338191
44149919
22
566816018
176157859
467765513
410
234
654790131
163506786
403377692
206990024
896
685811132
143
132
817158520
476333453
506732925
9
380
134873638
528025694
96
130452679
352654350
243130057
464184
392053697
839285798
148671320
492
157555902
74
268019428
881275983
37610...

result:

ok 100 numbers

Test #50:

score: 0
Accepted
time: 342ms
memory: 79340kb

input:

100
0 8 9 10
0 7 9 44
4 0 37 23
0 1 42 3
2 2 35 4
0 0 22 1
0 11 31 8
0 0 11 38
0 0 23 35
1 1 0 1
0 3 31 23
58 253 17 7
2 0 18 28
0 0 41 15
0 0 40 17
32 15 27 1
6 52 42 2
0 36 1 10
2 3 25 35
13 0 3 1
0 8 39 17
0 0 14 13
212 0 12 36
2 0 14 28
0 24 39 15
0 0 6 8
34 0 36 11
0 1 0 7
2 0 35 3
0 0 22 5
0 0...

output:

281336441
541161779
827034300
822030126
72648055
46
458009409
468
864
40
343902076
176527331
993288374
672
738
294806307
114023975
916301140
54629463
142616950
652102668
210
42922840
597009197
399737786
63
279214576
279
863120214
138
130
44474226
10
151526751
410
462427758
327301206
178978352
274939...

result:

ok 100 numbers

Test #51:

score: 0
Accepted
time: 102ms
memory: 75568kb

input:

100
0 0 42 13
0 2 8 13
0 1 25 4
1 0 30 28
0 0 16 41
0 0 14 5
0 0 0 44
1 0 17 35
0 37 9 20
0 1 20 39
9 0 0 6
0 5 29 30
0 0 11 17
0 0 28 26
2 0 7 26
0 0 9 39
0 0 33 11
0 2 43 0
0 0 40 6
0 0 24 25
0 1 1 0
0 0 23 8
12 2 8 34
0 4 4 24
0 0 13 12
0 0 21 8
3 0 35 0
3 1 20 26
0 3 19 10
15 0 27 13
9 0 27 20
8...

output:

602
799461924
394264960
469764604
714
90
45
795721254
793325326
133162784
422154746
716938969
216
783
172057010
400
408
558449555
287
650
9
216
159672413
636543869
182
198
819566578
757866142
779759561
454601995
711179912
260788227
787829318
164763392
288
78
228138552
505250487
715918704
585259531
5...

result:

ok 100 numbers

Test #52:

score: 0
Accepted
time: 143ms
memory: 75732kb

input:

100
0 21 27 15
0 0 31 4
1 2 35 21
6 5 3 24
0 0 19 4
18 0 0 14
0 9 34 29
0 0 14 5
0 5 12 9
0 0 23 38
0 12 25 27
0 0 41 18
0 2 7 4
20 0 33 29
0 0 33 21
2 0 14 42
2 0 5 39
17 4 29 34
2 5 0 13
0 0 28 15
3 0 28 18
8 0 42 4
20 0 28 34
19 0 38 7
0 0 12 16
6 21 12 5
0 8 44 8
21 14 3 22
0 1 5 1
0 0 5 43
6 0 ...

output:

178088472
160
330516018
170842287
100
163074966
649011061
90
213429194
936
196165235
798
522555
958458062
748
881732825
119547203
160636004
968232962
464
102853145
947091106
574553201
463416766
221
380915011
937429714
868599835
162
264
129917409
33948072
311603975
185
540243781
80
264970
270493172
6...

result:

ok 100 numbers

Test #53:

score: 0
Accepted
time: 170ms
memory: 75636kb

input:

100
2 0 11 1
0 8 13 42
0 0 7 13
1 0 44 0
9 136 12 43
37 0 16 40
0 3 23 36
0 0 14 21
0 0 12 8
0 0 44 0
0 0 16 2
1 0 22 38
0 0 19 7
0 0 12 21
0 0 30 10
0 0 41 17
0 93 20 36
5 9 18 35
87 30 0 1
0 5 8 41
2 7 40 17
1 0 0 28
0 0 30 13
12 0 7 27
0 1 1 12
0 11 33 30
0 0 16 33
0 6 37 3
4 0 8 2
1 8 6 19
0 0 4...

output:

123141502
25357620
112
251623128
710859487
935915007
679977397
330
117
45
51
254198570
160
286
341
756
69546429
573983149
797759297
242765581
377205825
536870998
434
202889436
20556
428043803
578
322670556
861825394
520805224
546
251623128
300
464246854
622277224
608
124781231
15047018
22
180449368
...

result:

ok 100 numbers

Test #54:

score: 0
Accepted
time: 172ms
memory: 79956kb

input:

100
1 3 3 32
0 0 13 10
0 0 13 22
7 5 40 0
0 3 0 8
0 0 11 3
0 26 27 4
1 6 11 18
0 1 24 22
0 0 19 28
0 31 19 16
19 22 29 28
8 1 28 30
0 0 17 12
0 2 32 12
0 0 3 12
0 103 3 43
0 0 10 9
0 0 18 3
1 0 9 43
0 0 0 20
0 0 15 15
93 3 6 6
0 0 41 11
19 0 28 35
0 7 7 43
0 0 17 39
0 0 11 29
0 1 14 31
4 1 21 10
0 0...

output:

321904682
154
322
228837524
125245612
48
605276514
757399000
838896738
580
636014798
503313398
39693686
234
782111096
52
230185249
110
76
669395790
21
256
278272595
504
989046083
773164016
720
360
536872273
964299431
392
473111626
736
625886758
4367948
75500193
504
946700104
916329410
153110970
8318...

result:

ok 100 numbers

Test #55:

score: 0
Accepted
time: 284ms
memory: 76824kb

input:

100
0 8 22 15
0 0 16 1
2 0 27 33
117 179 37 5
0 0 21 34
0 0 4 22
0 0 43 2
0 1 5 9
0 0 8 24
0 14 26 11
0 69 0 30
4 0 15 0
2 0 1 39
2 0 29 3
2 1 34 0
95 122 4 1
0 0 10 41
8 0 42 10
4 0 0 43
9 0 24 12
3 6 0 4
4 10 3 42
0 6 41 2
8 0 9 38
0 4 20 29
0 1 19 32
0 0 17 3
3 0 12 38
3 6 0 5
0 0 9 7
0 0 7 9
0 9...

output:

222294941
34
947683761
438009494
770
115
132
33966
225
719480689
565381562
675643115
705345303
826261066
455109798
998096947
462
585962195
792789721
381440724
146785380
979453025
35526848
770938984
512872397
12267574
72
796900446
642289112
80
80
33281505
360
922843348
220519948
770727062
627720984
8...

result:

ok 100 numbers

Test #56:

score: 0
Accepted
time: 225ms
memory: 75664kb

input:

100
3 0 34 15
8 4 0 44
0 0 14 8
0 0 36 12
7 0 19 7
8 0 41 14
0 0 1 41
4 0 24 37
0 1 30 14
0 0 38 20
2 0 22 25
0 2 2 15
2 1 3 41
0 0 42 11
0 4 38 13
10 0 12 39
0 0 20 13
3 0 11 17
0 8 35 25
0 21 9 16
0 0 11 18
0 1 39 17
0 0 31 30
6 35 37 18
0 51 21 8
0 3 37 14
0 0 11 5
1 2 4 34
0 0 13 0
0 0 28 23
0 3...

output:

256839790
700615993
135
481
976340268
481272215
84
111708148
235013416
819
261295483
770398731
986822835
516
779908979
620311757
294
367315307
617306103
45084827
228
583750527
992
982021374
108902629
473302839
72
472032411
14
696
974896966
195
419431126
168098100
399
745718403
732948460
80
766411270...

result:

ok 100 numbers

Test #57:

score: 0
Accepted
time: 184ms
memory: 79440kb

input:

100
27 0 14 32
1 0 26 0
0 0 7 36
8 2 27 7
22 14 22 24
12 0 6 34
0 0 35 3
7 0 11 43
22 0 8 6
26 26 9 42
0 6 37 14
0 0 5 4
0 2 15 8
0 5 30 28
3 0 23 7
26 0 11 19
0 0 11 42
54 0 31 30
2 13 3 43
0 1 25 36
0 3 0 43
5 2 16 30
30 75 26 1
7 0 4 40
0 0 9 3
2 54 9 15
0 3 14 7
0 0 1 28
0 0 18 5
0 0 1 17
0 2 10...

output:

802292331
134217808
296
46291302
842995055
303261678
144
817323927
399991814
974500932
830022885
30
314707487
279153828
635917922
193062117
516
378071530
306876254
459543411
770409585
335213496
698848766
337176813
40
804529190
600034304
58
114
36
542762682
247
621405753
513192224
605314902
102659748...

result:

ok 100 numbers

Test #58:

score: 0
Accepted
time: 115ms
memory: 75516kb

input:

100
0 4 9 44
0 1 16 42
1 7 16 42
0 0 31 25
0 43 4 43
8 0 1 20
0 1 5 43
9 0 13 21
19 62 43 5
5 1 7 43
1 0 30 1
0 0 5 8
0 19 1 1
0 0 17 37
5 0 0 2
9 0 8 8
27 8 35 7
0 5 9 32
9 73 26 35
0 12 34 28
6 0 41 12
0 0 39 18
2 0 43 0
0 0 26 29
0 0 29 1
7 36 12 22
0 4 29 12
2 5 10 23
0 0 5 5
11 1 35 6
0 1 27 7
...

output:

689860328
820605393
670851692
832
11508385
490576269
175560165
597004631
125806665
370860865
377487539
54
73800
684
3808
923304055
922192150
582938104
892393484
355662822
232257240
760
558449555
810
60
499264432
84867508
754964267
36
120305408
276824711
356243174
375157186
438883486
199005413
210471...

result:

ok 100 numbers

Test #59:

score: 0
Accepted
time: 166ms
memory: 74984kb

input:

100
0 0 1 36
0 0 9 18
0 0 0 12
0 96 18 40
0 0 15 34
0 0 40 0
5 0 1 20
0 0 9 44
0 0 38 6
0 3 22 15
0 41 10 18
0 2 35 18
20 0 5 17
0 21 1 43
18 0 13 0
8 0 43 5
0 0 31 28
41 0 44 4
0 28 13 10
0 0 33 5
23 0 41 14
78 79 13 17
0 0 6 14
0 0 2 1
19 1 13 13
1 0 18 0
98 47 37 1
2 0 5 0
8 45 18 9
2 0 13 39
9 0...

output:

74
190
13
134103150
560
41
592741160
450
273
878598264
257022640
833902512
170388551
303764135
870647981
408830060
928
39060677
460604878
204
351558356
68433545
105
6
582198438
524344
464074092
4727
556736427
379844720
827674898
85377402
480
976436757
390914332
268425352
515844010
698304022
79101707...

result:

ok 100 numbers

Test #60:

score: 0
Accepted
time: 206ms
memory: 77308kb

input:

100
0 3 20 16
2 5 16 9
9 0 42 0
12 45 28 30
6 0 6 7
4 0 13 11
0 0 23 38
0 0 1 26
2 2 28 2
0 8 15 2
1 0 4 23
0 0 20 36
3 0 34 0
1 33 35 24
5 1 32 9
0 0 11 25
0 0 30 30
0 0 40 10
1 5 36 13
0 0 1 34
0 17 24 6
2 0 21 7
0 0 36 12
0 3 35 10
1 30 24 3
1 0 16 11
0 0 27 26
0 0 14 29
3 2 38 4
3 7 13 30
2 1 15...

output:

211324288
54920891
41420382
866994441
861150474
766993632
936
54
168491933
645895771
83886435
777
458759913
113330434
750106442
312
961
451
974852131
70
700468749
472250456
481
130577912
812527749
269156952
756
450
201162724
327751277
30054110
90
14
288201659
616969119
833108224
840037673
402101038
...

result:

ok 100 numbers

Test #61:

score: 0
Accepted
time: 183ms
memory: 79316kb

input:

100
0 7 3 29
0 0 12 37
0 0 3 40
1 0 3 30
2 0 24 17
1 0 12 26
0 0 14 18
20 0 31 31
9 0 6 44
246 81 3 35
13 28 37 16
0 0 41 2
0 3 19 7
0 3 19 1
17 4 13 1
13 0 34 0
0 2 10 7
0 28 2 6
6 0 0 35
0 3 9 9
0 0 29 13
0 1 9 0
0 6 30 27
12 0 38 10
0 2 12 6
0 0 13 43
0 1 39 18
0 0 5 6
0 15 11 9
0 7 36 1
16 0 16 ...

output:

804982226
494
164
176161123
934662478
430048238
285
320985522
686176249
450562792
254080662
126
368091075
917339590
809326175
917558784
770921286
54995002
719288435
102855962
420
1053
375585190
345148845
41549256
616
100806495
42
349495711
582596531
129414624
924800657
900
850
810
779
662051547
205
...

result:

ok 100 numbers

Test #62:

score: 0
Accepted
time: 288ms
memory: 79300kb

input:

2
76 255 15 16
223 115 36 16

output:

84367518
30318999

result:

ok 2 number(s): "84367518 30318999"

Test #63:

score: 0
Accepted
time: 358ms
memory: 80256kb

input:

2
294 67 18 41
24 268 0 42

output:

411441431
553344889

result:

ok 2 number(s): "411441431 553344889"

Test #64:

score: 0
Accepted
time: 344ms
memory: 76972kb

input:

6
47 201 29 7
82 147 38 24
62 127 0 0
127 69 6 44
119 84 22 39
131 80 11 36

output:

478508450
397501560
65028096
401283467
229281463
433917451

result:

ok 6 numbers

Test #65:

score: 0
Accepted
time: 381ms
memory: 77216kb

input:

7
0 250 1 5
0 245 39 21
26 128 33 10
24 115 33 9
28 105 35 21
13 131 13 10
93 58 26 13

output:

92334020
59676885
158291624
819873666
576113877
579775390
138479552

result:

ok 7 numbers

Test #66:

score: 0
Accepted
time: 480ms
memory: 79772kb

input:

20
97 46 8 30
145 29 18 15
144 13 8 37
287 0 29 33
0 137 0 44
2 78 16 1
0 63 3 24
2 66 41 2
18 43 31 1
12 39 4 0
12 45 23 33
13 42 9 9
15 49 8 22
15 56 17 32
18 39 5 44
13 35 0 35
25 39 43 9
29 57 2 0
29 36 18 20
13 59 12 1

output:

455990550
657777084
574903956
122482322
934293620
858171780
88233261
674135421
78223990
51478945
963032627
412695985
349211793
844747165
587201530
235167928
879840638
813832867
350360039
77894441

result:

ok 20 numbers

Test #67:

score: 0
Accepted
time: 270ms
memory: 75800kb

input:

39
27 56 12 11
22 32 15 9
17 43 34 14
12 36 37 25
31 25 38 17
52 21 26 33
35 19 10 5
51 20 18 2
36 24 6 17
56 14 28 14
38 14 20 1
49 13 7 20
55 27 23 38
46 10 7 2
35 16 21 36
32 16 9 30
57 15 18 20
32 22 17 40
132 0 41 13
116 0 7 38
130 0 40 4
0 40 10 31
0 45 5 39
0 54 39 19
0 42 10 27
0 48 9 1
0 51...

output:

788117861
312943428
832519600
729448120
276476873
216607393
211388309
531115727
366840744
792011050
631274081
368284432
146177133
242852486
162853996
274462261
259950178
850609754
281790472
608790774
726955714
618721628
249741863
737285274
218481632
920106324
782445029
770424214
242160277
5010966
84...

result:

ok 39 numbers