QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#632855#7720. Even-dominant Numbersmemset0AC ✓167ms11572kbC++232.6kb2024-10-12 14:04:292024-10-12 14:04:29

Judging History

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

  • [2024-10-12 14:04:29]
  • 评测
  • 测评结果:AC
  • 用时:167ms
  • 内存:11572kb
  • [2024-10-12 14:04:29]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define all(x) begin(x), end(x)
#ifdef memset0
#define log(...) fprintf(stderr, __VA_ARGS__)
#else
#define endl '\n'
#define log(...) (void(0))
#endif
using namespace std;
using ll = long long;
using lf = long double;
using ull = unsigned long long;
const int M = 12;
const int AD = 20;
const int N = 1e6;
int T;
ll ss[2][15][(AD << 1) + 10];
ll ql, qr;
int tl, tr;
ll sum[N + 10];
int a[15], sz;
ll ans;
ll Calc(ll r, int fl) {
  // log("CALC %lld %d\n", r, fl);
  if (!r) return 0;
  sz = 0;
  while (r) a[sz++] = r % 10, r /= 10;
  ll ret = 0;
  for (int i = sz - 1; i >= 0; --i) {
    if (a[i] > 0) {
      if (i == sz - 1) {
        ret += ss[0][i][AD + 1 - fl];
      } else {
        ret += ss[1][i][AD + 1 - (fl + 1)];
      }
      ret += (a[i] - 1 >> 1) * ss[1][i][AD + 1 - (fl + 1)];
      ret += (a[i] >> 1) * ss[1][i][AD + 1 - (fl - 1)];
    }
    fl += ((a[i] & 1) ? -1 : 1);
  }
  // log("RET=%lld\n", ret + (fl > 0));
  return ret + (fl > 0);
}
int Count(ll x) {
  int ret = 0;
  while (x) {
    ret += ((x & 1) ? -1 : 1);
    x /= 10;
  }
  return ret;
}
ll Que(ll l, ll r, int fl) {
  // log("QUE in %lld %lld=%lld-%lld\n", l, r, Calc(r, fl), Calc(l - 1, fl));
  return Calc(r, fl) - Calc(l - 1, fl);
}
int Getsq(ll x) {
  int ret = (int)sqrt((lf)x);
  while (1ll * (ret + 1) * (ret + 1) <= ql) ++ret;
  return ret;
}
void Check(ll l, ll r, ll ans) {
  ll res = 0;
  for (ll i = l; i <= r; ++i) {
    res += (Count(i) + Count(Getsq(i)) > 0);
  }
  log("ANSWER=%lld\n", res);
  assert(res == ans);
}
int main() {
#ifdef memset0
  freopen("E.in", "r", stdin);
#endif
  // cin.tie(0)->sync_with_stdio(0);
  for (int i = 0; i <= AD; ++i) ss[1][0][i] = 1;
  for (int i = 1; i <= M; ++i) {
    // log("i=%d,M=%d\n", i, M);
    ss[1][i][0] = ss[1][i - 1][0] * 10;
    ss[0][i][0] = ss[0][i - 1][0] + ss[1][i - 1][0] * 9;
    for (int j = 1; j <= i + AD; ++j) {
      ss[1][i][j] = 5 * ss[1][i - 1][j - 1] + 5 * ss[1][i - 1][j + 1];
      ss[0][i][j] = ss[0][i - 1][j] + 4 * ss[1][i - 1][j - 1] + 5 * ss[1][i - 1][j + 1];
      // log("SS0 %d %d=%lld,SS1 %d %d=%lld\n", i, j - AD, ss[0][i][j], i, j - AD, ss[1][i][j]);
    }
  }
  for (int i = 1; i <= N; ++i) {
    sum[i] = sum[i - 1] + Que(1ll * i * i, 1ll * (i + 1) * (i + 1) - 1, Count(i));
  }
  cin >> T;
  while (T--) {
    cin >> ql >> qr;
    tl = Getsq(ql), tr = Getsq(qr);
    if (tl < tr) {
      ans = sum[tr - 1] - sum[tl];
      ans += Que(ql, 1ll * (tl + 1) * (tl + 1) - 1, Count(tl)) + Que(1ll * tr * tr, qr, Count(tr));
    } else {
      ans = Que(ql, qr, Count(tl));
    }
    cout << ans << "\n";
#ifdef memset0
    Check(ql, qr, ans);
#endif
  }
}

詳細信息

Test #1:

score: 100
Accepted
time: 127ms
memory: 11468kb

input:

1
1 10

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 119ms
memory: 11444kb

input:

10
2 5
7 9
5 5
2 4
2 2
7 9
3 9
1 10
5 8
1 10

output:

1
1
0
1
0
1
3
3
2
3

result:

ok 10 numbers

Test #3:

score: 0
Accepted
time: 127ms
memory: 11388kb

input:

10
17 18
1 20
2 5
7 14
5 20
1 15
1 12
5 11
2 13
9 19

output:

1
6
1
1
5
3
3
2
3
2

result:

ok 10 numbers

Test #4:

score: 0
Accepted
time: 123ms
memory: 11452kb

input:

10
7 16
2 2
4 8
9 30
3 11
11 12
7 27
18 30
3 10
6 11

output:

2
0
3
9
3
0
9
8
3
2

result:

ok 10 numbers

Test #5:

score: 0
Accepted
time: 123ms
memory: 11416kb

input:

10
18 39
5 35
7 29
32 35
40 40
18 39
27 29
15 21
10 15
7 15

output:

10
11
10
0
1
10
1
4
0
1

result:

ok 10 numbers

Test #6:

score: 0
Accepted
time: 127ms
memory: 11432kb

input:

10
19 48
13 14
15 36
11 35
40 43
19 20
16 43
7 25
13 49
21 26

output:

18
0
10
9
4
1
15
8
20
5

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 124ms
memory: 11448kb

input:

10
15 57
47 60
22 44
15 41
18 29
17 20
15 17
13 33
27 56
18 37

output:

20
3
12
13
8
2
1
9
12
9

result:

ok 10 numbers

Test #8:

score: 0
Accepted
time: 123ms
memory: 11448kb

input:

10
22 51
9 21
33 55
3 41
16 27
34 40
1 54
50 69
12 44
16 27

output:

16
4
11
16
8
3
23
8
16
8

result:

ok 10 numbers

Test #9:

score: 0
Accepted
time: 127ms
memory: 11468kb

input:

10
11 22
9 18
49 52
44 57
63 80
17 40
45 60
21 35
3 36
11 54

output:

5
2
0
5
12
11
5
6
13
20

result:

ok 10 numbers

Test #10:

score: 0
Accepted
time: 128ms
memory: 11320kb

input:

10
39 56
35 73
4 63
34 43
26 77
9 9
49 71
24 73
24 50
50 52

output:

9
21
25
6
25
0
9
24
14
0

result:

ok 10 numbers

Test #11:

score: 0
Accepted
time: 123ms
memory: 11516kb

input:

10
63 74
29 84
85 91
10 53
31 74
20 37
54 73
6 65
24 52
13 81

output:

9
27
2
20
22
8
10
26
14
34

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 122ms
memory: 11452kb

input:

1
1 1

output:

0

result:

ok 1 number(s): "0"

Test #13:

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

input:

100
266 801
95 374
7 308
650 706
399 822
788 826
888 944
489 946
131 616
445 654
434 522
101 661
532 961
568 903
276 758
325 395
56 850
378 711
83 184
268 322
501 555
772 785
516 857
149 948
82 268
841 939
593 717
3 334
83 103
732 776
64 736
122 274
455 748
889 954
90 640
212 717
135 211
37 483
144 ...

output:

304
76
106
49
298
34
20
295
228
144
74
268
262
239
277
8
420
239
17
16
28
4
226
442
56
54
104
111
5
10
344
50
204
21
253
293
19
178
270
284
264
15
96
18
51
164
111
327
31
395
113
36
347
371
148
11
67
408
332
253
392
410
128
317
25
276
353
470
21
115
331
104
3
70
265
42
181
80
342
170
115
125
179
50
...

result:

ok 100 numbers

Test #14:

score: 0
Accepted
time: 120ms
memory: 11388kb

input:

100
798 1399
654 1149
20 714
1216 1385
131 258
937 1028
337 376
954 1143
80 618
822 878
16 1136
1288 1336
828 1254
1241 1267
164 1138
466 1169
1368 1425
1361 1473
106 782
452 642
35 337
49 209
474 1381
809 943
25 527
1110 1495
567 1198
16 800
312 582
353 1097
927 1425
70 1050
239 819
533 1388
220 62...

output:

128
206
353
3
37
9
6
19
241
48
508
0
99
0
459
333
0
8
337
128
99
42
335
88
220
21
271
390
138
395
33
470
335
288
211
383
260
168
231
209
18
371
0
167
370
18
275
6
18
171
266
419
402
0
397
294
241
464
223
497
28
262
363
40
451
341
84
103
395
301
143
25
461
18
66
499
264
161
240
215
13
364
105
22
8
39...

result:

ok 100 numbers

Test #15:

score: 0
Accepted
time: 124ms
memory: 11524kb

input:

100
352 520
112 373
448 793
443 1878
822 1953
960 1700
614 830
447 1396
1353 1713
967 1537
862 1562
18 1774
268 293
1557 1607
210 1222
637 1762
423 1179
1574 1721
387 780
673 1356
386 1472
841 1670
457 1639
751 1723
933 1408
360 1816
1694 1915
1672 1840
545 1257
377 1518
1599 1863
635 1717
348 364
7...

output:

107
71
224
489
245
105
151
355
78
39
83
596
16
8
453
305
371
65
263
199
410
155
391
223
32
503
57
48
285
415
114
306
2
144
65
15
282
223
57
32
446
332
473
5
0
294
143
120
476
88
133
69
37
419
85
466
528
69
556
230
159
343
57
145
283
297
27
74
176
516
70
145
435
70
303
119
493
114
0
283
172
149
260
4...

result:

ok 100 numbers

Test #16:

score: 0
Accepted
time: 124ms
memory: 11448kb

input:

100
450 2076
46 2157
1693 1696
278 1223
149 151
661 2000
117 1751
1036 2194
1964 2058
2044 2080
97 1097
19 2007
422 1794
1571 2353
290 1023
385 610
1508 2164
526 902
1015 2094
75 264
1674 1864
655 1505
207 2081
1069 2138
751 1283
835 999
810 927
689 1316
643 672
483 2064
31 2133
507 536
1200 1254
94...

output:

566
765
0
420
0
361
551
318
58
27
470
672
466
399
385
152
259
251
254
55
58
226
674
265
145
66
84
185
24
534
756
17
8
385
416
79
156
39
292
422
18
132
480
454
8
387
464
23
336
115
408
559
132
263
766
503
54
566
388
203
679
238
551
418
145
473
4
452
365
27
179
700
3
4
702
319
120
78
334
571
120
3
366...

result:

ok 100 numbers

Test #17:

score: 0
Accepted
time: 124ms
memory: 11408kb

input:

100
1482 1710
41 488
312 1939
1472 2345
1429 1591
2428 2898
657 815
516 1352
2018 2841
2117 2130
482 2058
1022 2567
1104 2483
1127 2131
2204 2823
2350 2849
798 1806
1100 1783
1079 2244
1167 1284
2015 2783
1573 2120
912 1481
9 2589
519 2771
1240 1516
1085 2131
453 2234
753 2386
822 1550
877 1567
323 ...

output:

69
181
546
398
13
154
101
299
440
12
530
565
517
256
303
202
221
91
345
8
425
225
46
1061
885
13
258
675
582
118
71
452
267
201
591
655
15
78
627
164
1015
766
446
223
246
502
366
535
278
574
346
595
118
17
70
194
615
140
422
591
208
1060
3
373
210
488
424
87
21
0
550
122
184
767
678
42
362
493
420
1...

result:

ok 100 numbers

Test #18:

score: 0
Accepted
time: 128ms
memory: 11448kb

input:

100
1394 2025
1574 3487
2069 2925
563 1531
1408 1669
252 3390
2702 3325
503 2591
152 1802
628 2382
410 655
2289 2573
945 1729
2012 3183
557 1722
2552 3292
469 2926
2764 3325
2126 3430
2561 2906
3180 3216
1113 2309
661 831
1988 2338
1472 3403
612 2993
401 1833
910 2181
1047 1264
2358 2630
525 3449
13...

output:

176
673
416
294
68
1102
95
854
558
666
179
174
107
488
361
130
964
80
432
86
5
388
115
251
659
891
514
321
19
141
972
650
91
22
321
18
213
673
778
527
665
985
854
1119
553
105
935
369
15
460
691
50
474
499
560
668
122
258
353
128
580
908
402
825
358
899
672
598
637
218
953
111
69
9
369
827
970
990
2...

result:

ok 100 numbers

Test #19:

score: 0
Accepted
time: 125ms
memory: 11388kb

input:

100
2365 3496
781 2560
397 3389
188 1619
2991 3310
1690 3455
1364 3049
1272 1792
570 1100
985 2404
384 2016
2785 2917
666 768
1146 1165
490 1660
770 2294
1196 2163
872 2652
584 3927
3056 3090
904 2399
258 1850
2598 2946
816 1550
527 3652
1343 1961
1415 2531
1222 3653
975 2362
1793 2934
1940 3000
195...

output:

266
675
1067
492
23
602
650
86
270
476
569
31
65
0
381
510
279
621
1101
0
485
561
86
124
1018
141
530
730
444
541
508
525
318
29
244
595
290
355
635
1024
783
706
1122
204
63
800
224
508
37
39
449
303
129
1150
650
0
666
604
651
608
274
557
321
1052
1095
429
705
84
1263
1049
113
746
84
771
214
0
829
6...

result:

ok 100 numbers

Test #20:

score: 0
Accepted
time: 128ms
memory: 11436kb

input:

100
1585 1713
808 3579
987 3826
60 3785
513 2107
1143 3897
48 2418
2348 2797
186 2447
3147 4146
886 2373
1352 2290
2725 3406
2865 4200
2332 2828
622 1805
646 1414
3320 4286
668 4121
1451 2832
1235 4305
1052 1254
107 1628
596 876
3395 3784
1438 1807
732 2692
49 1075
1435 4288
1852 2289
413 1603
2565 ...

output:

65
805
802
1263
534
827
957
185
947
304
478
368
93
378
211
331
220
399
1137
604
1075
18
511
205
102
94
720
483
1066
242
406
131
517
857
717
1034
13
578
273
198
729
143
568
1386
205
1092
515
274
201
747
1185
965
691
456
1024
382
276
1155
808
655
13
47
460
587
284
832
424
768
1568
1114
243
1042
704
15...

result:

ok 100 numbers

Test #21:

score: 0
Accepted
time: 128ms
memory: 11436kb

input:

100
2162 3275
1341 1833
581 1427
2801 4586
848 1088
3066 4683
3280 3519
556 1040
3829 4657
1811 2925
5 100
1473 3951
1987 2782
288 4853
2276 2395
2816 4173
1865 2560
4162 4893
1666 1715
670 2708
2923 4230
1710 2435
126 4904
301 2532
1267 4066
787 2130
697 793
1042 4402
414 3307
743 2421
2910 3429
18...

output:

396
113
275
644
71
668
21
261
515
528
41
827
441
1843
88
372
408
497
14
774
399
395
1939
941
892
383
47
1144
1053
610
53
1099
418
673
673
62
468
464
1325
283
428
746
786
64
257
429
670
464
816
1161
403
400
487
840
1288
6
1399
1294
1138
421
731
15
377
505
630
336
938
1176
680
448
238
223
829
388
923
...

result:

ok 100 numbers

Test #22:

score: 0
Accepted
time: 148ms
memory: 11452kb

input:

10000
391154388456 393738543345
755996666604 780404969418
236995465488 891956288768
300448213236 697620314192
47808064840 385094135615
738782845381 973168872064
113336294761 972666969190
277089606036 578166653227
400735069251 728996269112
170040337284 433343024360
348774250904 378928478576
792489495...

output:

983180394
8428425500
269835041739
161199052277
132927063074
85293648023
339384147790
113925171335
144412334554
111428768269
9453481116
214822617156
150883916157
58701378111
26689370213
66311483023
162047155049
73157194449
339620782930
113105013098
94817747720
11381421473
24828169242
100799694747
887...

result:

ok 10000 numbers

Test #23:

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

input:

10000
118346975428 769683360759
408401750424 497154941199
66168082264 360226270541
582747919047 594240881337
649768466323 780698898421
501251574380 656321741472
641600257076 937176374645
56291553015 238069100258
496877904183 735586106001
316137281334 881889911699
197645482313 799467072408
1917788743...

output:

267154674456
51612990792
111371099169
3525988439
61260709050
49097428934
127066672300
77367986907
89852873148
233842297101
253776006111
80623985211
86701186777
50377171532
250791469680
6185283835
155203247661
231615594220
92400319751
71183667600
158283409206
16380201021
117477606565
26682240771
4438...

result:

ok 10000 numbers

Test #24:

score: 0
Accepted
time: 153ms
memory: 11316kb

input:

10000
762409190237 829160576600
275753939505 597789795102
677306346212 861088452810
5068475285 207181659118
258654554793 609213749185
843651351339 908575625710
67872206385 198182130496
767505666399 844175489069
56903206152 365491157431
118055709932 832555686802
12841057228 566441593282
305953614719 ...

output:

30003107989
119929922017
80838041325
82482001835
130710319439
25894639111
46195243440
32172542428
120494497615
295189508939
227983554648
149200478914
194195968560
16030669199
140249492786
10211978841
125668376736
183850739949
61486180515
151032308171
74930332246
15576556189
169539867100
15955461118
...

result:

ok 10000 numbers

Test #25:

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

input:

10000
149593161950 381489572869
399762592734 482749069442
96071608688 870319004671
462903557763 591312370596
16298301225 522402546094
189031467607 501202784865
49619127181 514091302311
82406194282 677506363218
463543956728 989523153371
61527922311 860055321828
205610485162 624596535893
799278134538 ...

output:

90512782296
49594746088
315740625351
42642333937
216289367167
142182846188
198840377775
237764176612
198532039558
330437264486
167916466320
64474178274
10338067811
174511379726
343445224675
55787578836
201563557362
39253219495
165140822511
245080165207
293322424020
172012438480
105081231992
13552085...

result:

ok 10000 numbers

Test #26:

score: 0
Accepted
time: 141ms
memory: 11384kb

input:

10000
747877350452 918313012317
305908861068 388185787999
435230494122 968052324953
181907638817 834136108552
201364891914 400526904342
229988318644 456671698546
714226473543 855386765004
374102843507 899494122558
358581122990 967532930032
259062850327 599041771036
79410324775 502351794144
791097663...

output:

66372736489
24023220229
210234308206
276748853628
79607271019
95680121871
58698428009
225016023574
248023626608
126508555157
179750637848
214636321349
331413115220
66259587585
1310975401
83026451137
103140776927
133841123556
346846694887
69570590110
168712914086
13752566721
149433533801
72807407588
...

result:

ok 10000 numbers

Test #27:

score: 0
Accepted
time: 152ms
memory: 11444kb

input:

10000
460972687865 475212657404
16842963452 814019333908
402621116388 801263556072
11916539562 352749544359
13925208356 305256544642
235720618274 887370042662
680168387890 733118464480
223295325478 807318197118
355886235800 680226877649
1010919634 799587624962
23105568101 156062131633
325309483272 8...

output:

9925599525
333547360883
171924957272
137215041180
125934540062
268299899325
25458777440
242939227460
138102515026
332530539705
53329449904
214212490843
229904668444
212389693301
156758181337
202311063595
372365598636
182629745119
243180981326
136104978173
9435556290
134175629087
163596681171
5964694...

result:

ok 10000 numbers

Test #28:

score: 0
Accepted
time: 167ms
memory: 11572kb

input:

10000
675482069308 940148930849
283948519541 570620928467
409689868579 612813396517
191978593755 833401954615
730502894712 888825080340
462037069535 913435884365
408199364118 522396755024
173217619024 956039489944
861648706752 913485894332
291249584499 993223745570
379860379236 968972476972
20896561...

output:

107059294592
110349900372
80182815819
272422503955
65414476437
181983295530
57660760140
318242042616
18214618289
270015744384
240021630973
290041772453
202997389397
187745858536
324889357834
88387880368
92024527298
12980924551
124621165836
136301611652
87109674199
384938528700
61602632511
7704274616...

result:

ok 10000 numbers

Test #29:

score: 0
Accepted
time: 155ms
memory: 11508kb

input:

10000
262866351986 702585299282
10924132966 753804571167
34572060263 939888614871
232766181887 364105224395
686976781493 811925887296
355934667548 758767993931
54547304889 493062045465
139376005933 626010518937
430627081889 798072408294
398628845601 418147457913
599429378706 786844426453
80273047002...

output:

177647825900
310295146469
370750272031
45609464160
53524387026
174308257388
190199674956
193518494392
153393138075
11297465212
87987276217
58284391988
14687888142
40018204680
22599907774
35535725901
97646173985
109548975686
56241044432
235289555787
312975823676
73245297115
302866645429
55702004066
3...

result:

ok 10000 numbers

Test #30:

score: 0
Accepted
time: 159ms
memory: 11452kb

input:

10000
55302778811 980318336052
183621972512 940086957074
535478679208 690731914782
208251778753 314010137160
140005797151 936105625640
195984653025 306081936775
373324092083 617888976570
783845825411 961740480383
174217136568 435592366809
313433097791 415450085913
300936621796 917858620118
194433702...

output:

368777511717
311161513321
62099415120
47624166040
325335496096
53511739045
97645351524
62115670018
111344863598
36809780464
248378932648
174420717538
118662009706
102733439835
139099791206
163470905477
237669313205
293748791684
216051942002
67640887824
83899069691
154852918028
22442162691
1871182888...

result:

ok 10000 numbers

Test #31:

score: 0
Accepted
time: 151ms
memory: 11452kb

input:

10000
77057047510 347693747984
508005220026 571920383754
190270637055 905365586850
191092339199 247713442198
133038264649 333190374639
532369392919 643921929707
844587736696 861492109163
228510782634 245193207533
608792412169 918833667156
554856871414 677665979504
231717357108 283279298674
470120900...

output:

103580448627
14039256116
300738295392
32135533993
79914977162
32653850246
7615063108
10065271842
134753085296
48532709108
24376839336
286200544283
248452546153
15879160803
76796579817
230312799722
14948301705
95361008368
159065797785
174099469590
25104527228
47259801867
114276266660
71864460459
7450...

result:

ok 10000 numbers

Test #32:

score: 0
Accepted
time: 138ms
memory: 11468kb

input:

10000
121 999999999997
52 999999999993
65 999999999985
89 999999999976
39 999999999925
90 999999999991
105 999999999969
24 999999999933
90 999999999992
39 999999999909
46 999999999932
37 999999999907
11 999999999902
49 999999999956
12 999999999967
110 999999999975
2 999999999997
82 999999999944
38 9...

output:

397369850991
397369851015
397369851012
397369850997
397369851024
397369850997
397369850994
397369851029
397369850997
397369851024
397369851018
397369851025
397369851035
397369851015
397369851035
397369850992
397369851038
397369851001
397369851025
397369851015
397369851036
397369850994
397369851035
3...

result:

ok 10000 numbers

Test #33:

score: 0
Accepted
time: 151ms
memory: 11452kb

input:

10000
44965583489 978664461154
269503223458 337848459305
52212845172 923564742306
198917797429 274763784620
503690766872 505128226316
184721431854 657825895581
128417228728 813980846603
383433790857 465468177661
249316218574 980357422279
334545152467 962880398632
15368135993 976168991732
28337391450...

output:

374562768086
20016010666
356382771370
40736763009
469120223
193810418086
283793373540
46076674966
284191121455
251591358971
386977306525
104840505017
187079452871
2422444540
317030512410
189903775885
72385542060
366256527540
93228712587
319154042688
45089767413
255575355576
377633177390
163829981839...

result:

ok 10000 numbers

Test #34:

score: 0
Accepted
time: 154ms
memory: 11452kb

input:

10000
76214121983 434594989775
16049961823 923011885442
52667832542 296790633760
375963115586 996946166313
152595001894 447177080568
557161474671 586625830541
17133928588 511302822032
586662592800 830069057541
57318367112 955028943065
1023077192 870187052156
57736627911 970524354768
60587764970 7914...

output:

143017119225
373668099102
104542881456
246110692916
127005768408
6963051934
214017457677
110447552769
361491433221
364166471031
365877522281
302803263367
191227802242
147538235980
178042195444
207057126402
286407100892
86203313858
136113717650
295266337525
245505928219
89394309397
240831448303
31785...

result:

ok 10000 numbers

Test #35:

score: 0
Accepted
time: 159ms
memory: 11448kb

input:

10000
81226635119 754281758310
650881225 633787460485
436136072 746883806105
542734025231 642860939078
655738162415 699888604472
1811444201 593067214460
320590151747 978627685556
588904281890 764267811704
611768070197 716049694414
81105098033 125969626063
588951722630 635704572228
37980403947 809757...

output:

274961448007
254457240034
311997641037
30450626436
24998541366
239604238520
259338748148
79744051285
53823551699
15594135660
15877477842
323600472199
179335855151
125700468860
384287814236
182475082642
52363813727
284275508427
301936940566
326841049927
23174332829
256217434695
165878608070
106911624...

result:

ok 10000 numbers

Test #36:

score: 0
Accepted
time: 162ms
memory: 11448kb

input:

10000
131929675499 854811551608
47054303088 464289652502
331779459124 888120587065
133195896505 940600145407
81465259749 949935695807
45223674764 983132136999
521090972632 659526850639
104093538171 839751556617
120506466828 763711063458
24244044610 506764195192
138624331127 604589295433
54025564138 ...

output:

299911036211
177627361748
233155273264
327364959988
346448441259
375337269102
46469557369
299796279716
264018871612
210368596665
183918227175
143398991553
107832222043
276837088513
390087221659
99212896471
364104407677
102643489335
81134714710
380525866776
322417221627
73525321001
57958749279
187524...

result:

ok 10000 numbers

Test #37:

score: 0
Accepted
time: 150ms
memory: 11368kb

input:

10000
1 1000000000000
795 682624484266
795 66682424
795 915959915999
795 2648828866
795 713311593
795 19517917595
795 4222262
795 7115933
795 575311399375
795 282446646484
795 15975133131
795 22628644822
795 7333737
795 591579719
795 95939737
795 37119119597
795 8682662884
795 82422286468
795 977937...

output:

397369851039
282853898556
26158564
378962158929
1215622295
286902977
7601695566
1656974
3570551
234993936809
123615272323
6623848612
9369576382
3694615
214802905
36957487
15168839363
4247808475
41666246429
4630054933
430141
63007137887
240820381065
4040892363
4904833
4832910
1205292271
2203178745
12...

result:

ok 10000 numbers

Test #38:

score: 0
Accepted
time: 149ms
memory: 11412kb

input:

10000
1 1000000000000
935 533791
935 53597575197
935 3359517
935 5339139
935 31915115
935 4426828622
935 977139773591
935 371779339173
935 4424888864
935 822248
935 66662828288
935 1113915175
935 915557375533
935 884282244266
935 79739793373
935 846266
935 844266466
935 957399313573
935 357775755
93...

output:

397369851039
253989
24863849890
1323301
2438794
12926419
2071482528
393781711949
150112933152
2069643503
398717
32414265788
441276771
378942105717
368457227332
39569282172
409232
348741087
388049567883
110336819
306407927
385759876
4311204322
41867548331
43368775907
258054766272
177996016196
322793
...

result:

ok 10000 numbers