QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#494823#9141. Array Spreaducup-team052#TL 1403ms129296kbC++203.7kb2024-07-27 17:08:312024-07-27 17:08:31

Judging History

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

  • [2024-09-18 18:58:44]
  • hack成功,自动添加数据
  • (/hack/840)
  • [2024-09-18 18:53:02]
  • hack成功,自动添加数据
  • (/hack/839)
  • [2024-07-29 03:53:23]
  • hack成功,自动添加数据
  • (/hack/753)
  • [2024-07-29 03:51:16]
  • hack成功,自动添加数据
  • (/hack/752)
  • [2024-07-29 03:50:24]
  • hack成功,自动添加数据
  • (/hack/751)
  • [2024-07-29 03:48:52]
  • hack成功,自动添加数据
  • (/hack/750)
  • [2024-07-27 17:08:31]
  • 评测
  • 测评结果:TL
  • 用时:1403ms
  • 内存:129296kb
  • [2024-07-27 17:08:31]
  • 提交

answer

#pragma GCC optimize("-ffp-contract=fast")
#include <bits/stdc++.h>
using namespace std;

const int md = 998244353;

inline int mul(int x, int y) {
    return 1ull * x * y % md;
}

inline int fpow(int x, int y) {
    int ans = 1;
    while (y) {
        if (y & 1) ans = mul(ans, x);
        y >>= 1; x = mul(x, x);
    }
    return ans;
}

const int N = 4005;

int l[N], r[N], b[N];
int T, n, m;

namespace dcx {

const int N = 4005, M = 4005;
const double eps = 1e-6;

double a[M][N];
int n, m;

void pivot(int r, int c) {
    double tmp = -a[r][c]; a[r][c] = -1;
    for (int i = 0; i <= n; i++) a[r][i] /= tmp;
    for (int i = 0; i <= m; i++) {
        if (i != r && fabs(a[i][c]) > eps) {
            tmp = a[i][c]; a[i][c] = 0;
            for (int j = 0; j <= n; j++) a[i][j] += tmp * a[r][j];
        }
    }
}

double simplex() {
    a[0][0] = 0;
    while (1) {
        int r = -1;
        for (int i = 1; i <= m; i++) {
            if (a[i][0] < -eps) {
                if (r == -1 || a[i][0] < a[r][0]) {
                    r = i;
                }
            }
        }
        if (r == -1) break;
        int c = -1;
        for (int i = 1; i <= n; i++)  {
            if (a[r][i] > eps) {
                c = i;
                break;
            }
        }
        assert(c != -1);
        pivot(r, c);
    }
    while (1) {
        int c = -1;
        for (int i = 1; i <= n; i++) {
            if (a[0][i] > eps) {
                c = i;
                break;
            }
        }
        if (c == -1) break;
        int r = -1; double lim;
        for (int i = 1; i <= m; i++) {
            if (a[i][c] < -eps) {
                double now = a[i][0] / -a[i][c];
                if (r == -1 || now < lim) {
                    lim = now;
                    r = i;
                }
            }
        }
        assert(r != -1);
        pivot(r, c);
    }
    return a[0][0];
}

}

int main() {
	__builtin_ia32_ldmxcsr(40896);
    scanf("%d", &T);
    while (T--) {
        scanf("%d%d", &n, &m);
        for (int i = 1; i <= m; i++) {
            scanf("%d%d", &l[i], &r[i]);
            b[i] = l[i]; b[i + m] = r[i] + 1;
        }
        sort(b + 1, b + 2 * m + 1);
        int len = unique(b + 1, b + 2 * m + 1) - b - 1;
        dcx::m = m * 2;
        dcx::n = len + 1;
        for (int i = 1; i <= len; i++) dcx::a[0][i] = 0;
        dcx::a[0][len + 1] = -1;
        for (int i = 1; i <= m; i++) {
            l[i] = lower_bound(b + 1, b + len + 1, l[i]) - b;
            r[i] = lower_bound(b + 1, b + len + 1, r[i] + 1) - b - 1;
            for (int j = 0; j <= len + 1; j++) {
                dcx::a[i * 2 - 1][j] = dcx::a[i * 2][j] = 0;
            }
            for (int j = l[i]; j <= r[i]; j++) {
                dcx::a[i * 2 - 1][j] = 1;
                dcx::a[i * 2][j] = -1;
            }
            dcx::a[i * 2 - 1][0] = -1;
            dcx::a[i * 2][len + 1] = 1;
        }
        double res = -dcx::simplex();
        // fprintf(stderr, "res = %.6lf\n", res);
        double mn = 1e9;
        int ans = 0;
        for (int i = 1; i <= m; i++) {
            int j = floor(i * res + 0.5);
            double diff = fabs((double)j / i - res);
            // fprintf(stderr, "i = %d, j = %d\n", i, j);
            if (diff < mn) {
                mn = diff;
                ans = mul(j, fpow(i, md - 2));
                // fprintf(stderr, "ans = %d, i = %d, j = %d, diff = %.6lf\n", ans, i, j, diff);
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

/*
3
3 3
1 3
2 3
1 2
12 6
2 3
5 7
1 9
4 8
1 2
7 11
4 5
3 4
2 3
1 2
4 4
1 1
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3928kb

input:

3
3 3
1 3
2 3
1 2
12 6
2 3
5 7
1 9
4 8
1 2
7 11
4 5
3 4
2 3
1 2
4 4
1 1

output:

1
2
499122178

result:

ok 3 number(s): "1 2 499122178"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

2000
1000000000 1
259923446 367011266
1000000000 1
882434225 971573327
1000000000 1
41585677 470369580
1000000000 1
371902212 947250194
1000000000 1
787209148 924205796
1000000000 1
259074809 960876164
1000000000 1
148079314 188254573
1000000000 1
940091047 948318624
1000000000 1
40636497 743979446
...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 2000 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 3988kb

input:

1000
1000000000 5
575330909 661595447
708422488 913945134
658050911 930246647
786571892 904549453
851755566 969150871
1000000000 2
198072104 844159589
8876188 644559580
1000000000 2
740802634 976972118
783909534 898449184
1000000000 2
871819537 941611957
465883854 640988372
1000000000 1
99458969 462...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
...

result:

ok 1000 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 5976kb

input:

500
1000000000 13
964546318 987364574
367845944 907446075
259314137 890312338
458318546 959971971
353677471 522446336
782931403 845199078
514387878 786979588
532634932 793056892
905393511 960628299
747423889 986373313
796099347 833069525
906969434 971335651
574582540 647534593
1000000000 6
987712893...

output:

3
1
3
1
1
1
1
1
1
3
2
1
1
1
3
1
2
1
1
2
1
3
1
1
1
2
1
2
2
1
1
1
1
1
1
1
3
1
1
1
1
2
1
1
1
1
2
1
1
1
1
1
2
1
1
1
1
1
1
1
2
2
1
1
3
1
2
1
1
1
1
2
3
1
1
1
1
1
1
1
3
2
1
3
2
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
3
1
1
1
1
1
1
1
2
1
1
2
1
1
1
2
1
4
1
2
1
4
1
3
1
1
1
1
1
2
1
1
4
1
...

result:

ok 500 numbers

Test #5:

score: 0
Accepted
time: 2ms
memory: 8176kb

input:

250
1000000000 10
844342043 888135880
127033337 726074967
581308029 893912240
414276384 752837267
565680461 863374082
230362895 477723054
210479116 423381051
325072305 427826920
178306222 756423471
376470949 993759748
1000000000 2
468173597 607783582
266359996 863641680
1000000000 7
206599093 941381...

output:

2
1
2
1
3
3
1
1
1
2
1
2
2
1
3
5
2
1
1
1
2
1
2
1
3
1
2
1
3
499122178
1
1
1
1
3
1
1
1
3
3
3
1
4
1
1
1
1
1
1
1
1
5
1
4
2
1
3
1
1
1
2
5
2
1
2
6
2
2
1
2
1
1
1
5
8
2
1
2
1
1
2
2
2
1
1
5
8
3
1
1
1
8
2
6
1
1
4
2
1
1
1
1
2
2
1
2
1
1
1
1
1
1
2
1
2
1
1
4
1
1
3
1
2
3
3
2
5
1
1
1
3
2
1
1
1
3
1
1
2
1
1
1
1
3
1
1
...

result:

ok 250 numbers

Test #6:

score: 0
Accepted
time: 2ms
memory: 8176kb

input:

250
1000000000 4
10495745 465086423
465086424 609997778
396956207 663037010
253873206 396956206
1000000000 33
596279983 655818820
226461062 338625457
407323582 423049163
711408063 778512581
220274357 226461061
702491412 711408062
686978949 688730316
369564474 434159428
778512582 787885602
675683057 ...

output:

1
2
748683266
5
6
453747435
1
10
6
1
499122183
1
4
3
1
3
1
748683266
2
499122179
10
499122178
1
499122179
4
1
7
1
665496238
2
2
2
332748119
249561090
816745381
499122178
2
499122179
5
3
4
17
1
2
2
3
249561092
1
3
924300328
499122179
2
3
332748120
2
7
3
499122187
6
374341634
1
2
332748120
2
2
2
49912...

result:

ok 250 numbers

Test #7:

score: 0
Accepted
time: 4ms
memory: 10228kb

input:

100
1000000000 17
272213590 960979163
970159974 987653658
201788340 556786243
46564706 948945765
786605927 819103747
510930374 747773556
729597186 850647589
412727504 443334406
685627406 773178988
793614323 909668193
830162056 837607472
416766039 753918198
237455713 993045890
848459092 851118478
463...

output:

8
1
1
2
3
3
1
5
1
2
8
2
1
1
3
1
3
6
3
3
2
3
7
2
1
1
3
1
2
1
5
5
2
2
4
2
7
2
1
6
1
2
5
4
5
4
1
1
1
8
6
1
4
4
5
13
1
4
9
4
8
3
8
5
4
7
1
8
1
1
1
9
2
1
6
4
4
3
1
1
1
10
4
6
11
6
6
1
1
4
1
4
2
2
13
5
1
1
5
8

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 3ms
memory: 10160kb

input:

100
1000000000 49
187775019 193881727
145323628 162242601
964365230 971504847
226437670 229819402
46971378 49331905
871327590 883354570
310535966 323031740
904117712 916571909
458902934 484636144
13320536 14923771
571938132 574937141
89751784 102733764
412667720 421251698
908036941 932886651
2663244...

output:

2
1
1
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
2
1
1
1
2
3
1
1
1
1
1
1
3
1
3
1
1
1
1
1
1
1
1
2
1
1
1
2
1
1
3
1
1
1
1
3
1
1
1
1
1
2
1
1
1
1
1
2
1
2
2
1
1
1

result:

ok 100 numbers

Test #9:

score: 0
Accepted
time: 3ms
memory: 8260kb

input:

100
1000000000 33
607773622 612059886
773446566 927093401
216659567 357373353
949986996 960422356
67865304 185683459
748675762 867719748
419805439 434936264
83601801 106508219
584299087 639485780
487166380 588591547
670602250 789210083
877816826 902687951
800334389 834278741
90815648 214176329
53952...

output:

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

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 3ms
memory: 10248kb

input:

100
1000000000 27
423127198 447304856
209683651 219301129
831320345 879604518
631502329 814498734
130918283 202258454
434769186 463838309
448295746 500976275
778017547 864887407
60178254 66348236
615735891 725460273
78684718 129678593
219427409 221445385
242513397 378886240
549135209 710348598
24951...

output:

748683266
2
332748119
2
855638018
2
2
2
1
1
499122179
1
630470119
1
873463814
10
3
598946613
499122178
499122179
720954257
24956110
686292996
499122178
6
2
499122180
332748122
665496237
27
17
1
15
5
199648872
6
4
3
1
285212675
2
1
4
2
499122186
698771050
844668300
887328319
332748120
1
2
499122179
4...

result:

ok 100 numbers

Test #11:

score: 0
Accepted
time: 0ms
memory: 12344kb

input:

50
1000000000 54
393385964 584227315
530511168 878333402
240442438 693353417
66549203 383382851
432995043 781030135
902504635 941834946
40257869 409360381
186795487 285734229
500620269 578283640
769614926 881642580
651338390 854914246
220143804 506609845
486528251 695975933
659594236 951619961
26914...

output:

6
3
9
1
5
1
5
7
4
9
11
7
4
10
1
1
3
1
1
7
11
12
7
6
6
7
1
14
9
5
3
11
7
5
10
1
1
14
2
8
16
4
4
2
2
6
4
1
1
9

result:

ok 50 numbers

Test #12:

score: 0
Accepted
time: 3ms
memory: 16304kb

input:

50
10 65
7 10
3 6
5 7
7 7
3 9
2 2
3 10
10 10
7 7
2 3
5 6
7 10
3 9
2 8
2 8
8 8
4 8
9 9
9 9
7 9
1 1
3 6
9 10
9 10
2 3
7 8
9 10
2 9
9 10
10 10
5 7
6 10
6 8
4 5
10 10
5 5
5 10
8 8
1 9
6 7
3 6
1 9
2 5
1 10
2 9
8 9
8 8
1 1
2 9
4 9
10 10
7 10
2 3
8 9
10 10
2 4
2 9
4 7
1 3
1 9
10 10
1 4
8 9
7 8
7 8
10 88
6 ...

output:

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

result:

ok 50 numbers

Test #13:

score: 0
Accepted
time: 11ms
memory: 18464kb

input:

25
1000000000 126
107069149 368376053
479032115 765537110
991540256 997326292
403046092 722244014
490526523 516722534
274125538 310843747
777271932 894507975
30859549 117930127
295842439 932626190
696990395 727705976
919364307 981912430
452436750 754049053
436429356 707440965
255169020 717543449
875...

output:

13
12
14
15
3
8
13
499122178
9
17
3
3
5
6
6
22
3
3
16
6
17
5
6
9
19

result:

ok 25 numbers

Test #14:

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

input:

10
1000000000 69
870434015 950861762
463726401 635711398
333118041 890448132
290535922 477961269
413309490 468893401
200588542 259174530
820993949 902249431
919016091 952057155
32176623 226256591
307850591 328322116
544612131 956816575
794988232 980183910
896176727 934471390
445409718 674881616
3109...

output:

7
21
17
13
6
11
30
26
17
14

result:

ok 10 numbers

Test #15:

score: 0
Accepted
time: 43ms
memory: 53076kb

input:

10
1000000000 226
722573032 815472621
582575925 607010515
411370955 463267466
92061989 217643130
187859011 258319855
811376535 844552673
426496326 431292091
785538560 983675713
328209738 364768843
338697990 509158393
502285144 536085577
202590577 293138489
873383022 956559039
765186726 836986281
219...

output:

15
5
5
12
18
2
13
12
35
8

result:

ok 10 numbers

Test #16:

score: 0
Accepted
time: 5ms
memory: 30664kb

input:

10
10 31
7 8
5 9
2 4
6 10
10 10
4 5
3 6
8 8
4 10
7 8
2 8
2 7
3 4
9 9
4 7
1 8
1 10
3 9
2 5
5 8
5 8
5 8
6 6
2 10
3 7
9 10
9 10
7 7
6 6
9 10
6 7
10 165
10 10
9 9
4 9
9 9
1 1
6 8
2 9
4 6
10 10
8 9
5 9
8 8
6 10
6 6
4 6
1 6
3 7
5 9
2 8
5 6
3 5
6 9
6 8
4 7
5 8
9 9
5 7
10 10
5 8
9 10
5 5
3 8
7 10
1 1
7 8
6 ...

output:

6
9
10
10
10
7
9
9
8
9

result:

ok 10 numbers

Test #17:

score: 0
Accepted
time: 97ms
memory: 67680kb

input:

5
1000000000 63
619459262 977043459
300995683 982228427
410548612 621234006
122929033 763884440
421486730 819706101
340188689 623537684
507398179 844353491
337184385 791508531
349294635 959826734
98096933 650360479
385580668 846357810
364950155 640902318
640098682 994083922
770432519 820631492
66011...

output:

8
17
6
40
44

result:

ok 5 number(s): "8 17 6 40 44"

Test #18:

score: 0
Accepted
time: 482ms
memory: 127120kb

input:

2
1000000000 1954
214176902 795098577
427614652 861416360
690405909 903037538
224031724 678866146
103017905 175158461
481177251 880591454
774838238 795104831
887429528 996876768
889351335 987035745
391908934 489988622
83670551 709453888
679022699 842242196
78153409 642923089
232797325 414737043
6804...

output:

66
8

result:

ok 2 number(s): "66 8"

Test #19:

score: 0
Accepted
time: 434ms
memory: 128972kb

input:

1
1000000000 2000
804998774 935072473
539475366 898950940
227523606 852755701
309719052 650340983
356982928 655220770
783115802 937764030
570168460 665560212
583166562 906377079
947557671 947616592
774446890 997986030
113320562 897048797
39935214 749273732
63763440 415540685
961986268 990569362
9656...

output:

62

result:

ok 1 number(s): "62"

Test #20:

score: 0
Accepted
time: 496ms
memory: 129172kb

input:

1
1000000000 2000
983082198 998118377
133255920 610572950
206872860 997430403
184715228 358714182
577917083 618946695
457376242 788935995
213001254 402552678
805136885 901023068
230805393 394264451
647877612 836521262
260384310 990902247
409818531 847221384
791110001 876700979
380113193 775384241
98...

output:

68

result:

ok 1 number(s): "68"

Test #21:

score: 0
Accepted
time: 504ms
memory: 129168kb

input:

1
1000000000 2000
866198326 984959665
577293370 619895730
40997921 614353847
619519915 762112999
653627047 934559654
836669385 838221693
150801344 848367607
172331400 524704520
514053116 611706075
816275630 945128934
552672251 875377371
924926041 974390075
958648050 977057013
388174710 757781221
867...

output:

65

result:

ok 1 number(s): "65"

Test #22:

score: 0
Accepted
time: 0ms
memory: 127084kb

input:

1
10 2000
3 10
7 9
9 10
4 9
9 10
10 10
5 10
5 8
9 9
8 8
2 8
2 9
4 9
1 4
4 8
7 8
1 3
9 10
5 7
7 9
7 10
5 8
2 7
8 9
2 10
5 6
8 9
4 5
8 8
7 10
7 10
10 10
6 7
5 10
7 10
9 10
1 4
3 6
9 9
7 9
8 9
3 9
3 5
8 10
3 6
3 9
3 10
3 9
4 6
9 10
4 8
4 9
8 10
1 2
10 10
8 9
2 7
5 5
4 6
7 7
1 3
1 5
2 6
8 9
1 8
8 8
8 9
...

output:

10

result:

ok 1 number(s): "10"

Test #23:

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

input:

1
100 2000
72 77
22 100
39 72
24 62
16 60
72 79
10 83
25 73
65 80
25 52
66 69
59 62
40 64
23 49
52 52
9 29
10 77
98 99
54 69
13 17
40 61
4 21
49 91
24 71
40 96
33 97
81 99
75 99
45 62
34 56
44 96
15 21
18 63
73 81
35 98
97 100
3 8
54 71
14 67
89 91
69 78
54 63
55 82
26 99
21 97
87 89
19 86
47 80
5 3...

output:

53

result:

ok 1 number(s): "53"

Test #24:

score: 0
Accepted
time: 505ms
memory: 128972kb

input:

1
1000000000 2000
269842809 342989075
757696397 836492119
283800102 368175835
822590805 872323042
941319254 945363554
281911546 293866204
38600498 86445775
480456857 512409031
93001458 142464233
444440343 481314857
199837475 390806080
247541526 359208697
91559247 103334865
843979563 922498813
219394...

output:

56

result:

ok 1 number(s): "56"

Test #25:

score: 0
Accepted
time: 414ms
memory: 129168kb

input:

1
1000000000 2000
60970930 249531903
605655603 691131570
118119998 120991935
847802043 855924405
584102854 586717700
472229670 472514717
644930188 651241444
827728709 830128844
13795393 40329809
305610899 308346192
701926206 707118828
753530803 795196944
465598902 506244732
289441054 295066017
31306...

output:

48

result:

ok 1 number(s): "48"

Test #26:

score: 0
Accepted
time: 325ms
memory: 129088kb

input:

1
1000000000 2000
536271720 567640349
500139615 505304625
983805617 983975201
94383607 147481725
660146910 669771610
383881741 388232026
270977785 281138547
732093947 763594417
916230529 918169865
840991913 842180384
148110570 190711924
234960944 320094883
471183646 473316949
589311548 599607524
843...

output:

36

result:

ok 1 number(s): "36"

Test #27:

score: 0
Accepted
time: 311ms
memory: 129104kb

input:

1
1000000000 2000
253665547 265466414
680907838 683090293
624375234 634603777
122927162 123370400
796036172 809472081
44051418 53038658
805455233 813555754
598048351 601880671
890314580 907216922
71975295 73805827
210790640 215291615
7828762 11464474
755748 9933627
403981737 405251546
203053255 2073...

output:

29

result:

ok 1 number(s): "29"

Test #28:

score: 0
Accepted
time: 191ms
memory: 129168kb

input:

1
1000000000 2000
405154724 415180094
217599764 236947592
443502690 445411390
704018773 736978289
411258264 417952279
74830932 83239763
549851687 550072757
78499713 79178089
386983274 389145943
904368883 908143439
573835921 579550046
461692563 462204357
737455142 749312955
201370027 208562823
800400...

output:

18

result:

ok 1 number(s): "18"

Test #29:

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

input:

1
1000000000 2000
636241745 637184786
72054834 72845369
389843249 390664964
168145795 172118428
893106799 895704067
299524880 300801439
29663110 31018768
821696497 823269898
555248504 561118852
786551669 788495535
241984595 244010309
88896181 90154078
409626569 413026599
276562518 278971540
34098107...

output:

12

result:

ok 1 number(s): "12"

Test #30:

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

input:

1
1000000000 2000
775300798 775887545
414455164 414765933
482698418 483451742
61950757 62192271
660326268 660527972
631032663 631204978
697002803 698108853
355102397 355611777
428369246 428537339
804557428 805328473
927694064 928207744
45269484 45777489
8814283 9209856
715864772 716035358
298335301 ...

output:

14

result:

ok 1 number(s): "14"

Test #31:

score: 0
Accepted
time: 103ms
memory: 128976kb

input:

1
1000000000 2000
767922821 767991850
289504691 289531721
251731008 251917208
674093628 674196482
531956403 531991130
629214886 629249556
258581533 258771850
376924559 377133497
384702776 384846804
597904466 597997168
225891755 225975116
181703875 181793417
496608917 496630853
949582964 949591315
85...

output:

3

result:

ok 1 number(s): "3"

Test #32:

score: 0
Accepted
time: 109ms
memory: 128976kb

input:

1
1000000000 2000
228893800 228908417
247092434 247118950
444005072 444005307
11611034 11617481
174532875 174543185
817918839 817922625
970187539 970190706
670081522 670119433
387831247 387855683
302583713 302586447
247247304 247256686
378883005 378894127
227362402 227363360
1961915 1971640
18341639...

output:

2

result:

ok 1 number(s): "2"

Test #33:

score: 0
Accepted
time: 94ms
memory: 129296kb

input:

1
1000000000 2000
57718020 57719049
666380062 666380395
749991324 749991702
892182872 892183353
801943437 801944028
79294169 79294302
555724391 555726783
33922986 33924967
140433140 140433755
885613046 885614480
541055072 541055603
591953292 591956152
486054735 486054958
937249219 937249446
71466373...

output:

1

result:

ok 1 number(s): "1"

Test #34:

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

input:

20
1000000000 41
942725914 956893525
130968778 136999877
528516274 534235456
144476363 150040417
758242783 765399242
43829675 51184350
508202014 513231158
918241923 924218108
662727534 806406887
392873650 493267077
56851982 60477276
290204036 310321327
431216970 440055845
636193295 649883208
2731659...

output:

142606341
3
332748145
218365954
199648872
17
124780547
399297746
86803859
20
554580202
840358768
221832083
695746068
17
516947970
449758446
949942208
332748124
3

result:

ok 20 numbers

Test #35:

score: 0
Accepted
time: 97ms
memory: 30812kb

input:

10
1000000000 417
627781142 629714760
598651777 602008259
852433806 853778002
886286857 888427504
789562767 794791071
982787290 984372848
156909491 157679027
846484388 851062802
157686024 161849304
960912238 962168439
472530654 482013887
281175472 286597312
701329984 702139905
688522549 692226383
23...

output:

87056195
698771053
570425402
862120129
199648873
142606341
564225074
13
499122215
771370646

result:

ok 10 numbers

Test #36:

score: 0
Accepted
time: 705ms
memory: 129032kb

input:

1
1000000000 2000
213239071 213382300
339117973 339530479
825361841 826092857
339970803 339980741
798713033 798740067
542540242 542736231
62765592 63346300
641000665 641054005
692199416 692257820
77404143 78416629
950702620 950907897
504833797 505142552
572971840 573068998
340559923 340656260
251909...

output:

390617398

result:

ok 1 number(s): "390617398"

Test #37:

score: 0
Accepted
time: 1403ms
memory: 129168kb

input:

1
1000000000 2000
883470303 883719058
823526735 823959348
713754093 713993403
506510792 507594225
13182808 13603988
648514473 648713042
130046376 131842867
601735303 602293659
626791988 626875924
880105881 880170880
656055622 656402411
770474419 770938733
454034089 454108708
227332224 227471558
5167...

output:

252429617

result:

ok 1 number(s): "252429617"

Test #38:

score: -100
Time Limit Exceeded

input:

1
1000000000 2000
495216860 495381961
847680317 849382419
319281395 319333520
914985917 916233726
24433548 26044838
693088888 693983327
341755448 344295495
524313786 525774106
765723876 766023685
392333153 393124859
768866295 769238480
438757588 441413808
682278132 682966544
533511719 533562147
5131...

output:


result: