QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501218#2270. LCM of GCDsyzkkai#AC ✓222ms12152kbC++204.1kb2024-08-02 15:46:262024-08-02 15:46:27

Judging History

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

  • [2024-08-02 15:46:27]
  • 评测
  • 测评结果:AC
  • 用时:222ms
  • 内存:12152kb
  • [2024-08-02 15:46:26]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) signed(size(x))
using namespace std;
using ll = long long;
using LL = long long;
struct Info {
    LL lcm0 = 0, lcm1 = 0, lcm2 = 0;
};

Info operator+(Info a, Info b) {
    return {
        gcd(a.lcm0, b.lcm0), 
        lcm(gcd(a.lcm0, b.lcm1), gcd(a.lcm1, b.lcm0)),
        lcm(gcd(a.lcm1, b.lcm1), lcm(gcd(a.lcm0, b.lcm2), gcd(a.lcm2, b.lcm0)))
    };
}

template<class Info>
struct SegmentTree {
    int n;
    vector<Info> info;
    SegmentTree() : n(0) {}
    SegmentTree(int n_, Info v_ = Info()) {
        init(n_, v_);
    }
    template<class T>
    SegmentTree(vector<T> init_) {
        init(init_);
    }
    void init(int n_, Info v_ = Info()) {
        init(vector(n_, v_));
    }
    template<class T>
    void init(vector<T> init_) {
        n = init_.size();
        info.assign(4 << __lg(n), Info());
        std::function<void(int, int, int)> build = [&](int p, int l, int r) {
            if (r - l == 1) {
                info[p] = init_[l];
                return;
            }
            int m = (l + r) / 2;
            build(2 * p, l, m);
            build(2 * p + 1, m, r);
            pull(p);
        };
        build(1, 0, n);
    }
    void pull(int p) {
        info[p] = info[2 * p] + info[2 * p + 1];
    }
    void modify(int p, int l, int r, int x, const Info &v) {
        if (r - l == 1) {
            info[p] = v;
            return;
        }
        int m = (l + r) / 2;
        if (x < m) {
            modify(2 * p, l, m, x, v);
        } else {
            modify(2 * p + 1, m, r, x, v);
        }
        pull(p);
    }
    void modify(int p, const Info &v) {
        modify(1, 0, n, p, v);
    }
    Info rangeQuery(int p, int l, int r, int x, int y) {
        if (l >= y || r <= x) {
            return Info();
        }
        if (l >= x && r <= y) {
            return info[p];
        }
        int m = (l + r) / 2;
        return rangeQuery(2 * p, l, m, x, y) + rangeQuery(2 * p + 1, m, r, x, y);
    }
    Info rangeQuery(int l, int r) {
        return rangeQuery(1, 0, n, l, r);
    }
    template<class F>
    int findFirst(int p, int l, int r, int x, int y, F pred) {
        if (l >= y || r <= x || !pred(info[p])) {
            return -1;
        }
        if (r - l == 1) {
            return l;
        }
        int m = (l + r) / 2;
        int res = findFirst(2 * p, l, m, x, y, pred);
        if (res == -1) {
            res = findFirst(2 * p + 1, m, r, x, y, pred);
        }
        return res;
    }
    template<class F>
    int findFirst(int l, int r, F pred) {
        return findFirst(1, 0, n, l, r, pred);
    }
    template<class F>
    int findLast(int p, int l, int r, int x, int y, F pred) {
        if (l >= y || r <= x || !pred(info[p])) {
            return -1;
        }
        if (r - l == 1) {
            return l;
        }
        int m = (l + r) / 2;
        int res = findLast(2 * p + 1, m, r, x, y, pred);
        if (res == -1) {
            res = findLast(2 * p, l, m, x, y, pred);
        }
        return res;
    }
    template<class F>
    int findLast(int l, int r, F pred) {
        return findLast(1, 0, n, l, r, pred);
    }
};


inline void solve() {
    int n, q;
    cin >> n >> q;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    SegmentTree<Info> seg(n);
    for (int i = 0; i < n; i++) {
        seg.modify(i, {a[i], 0, 0});
    }

    while (q--) {
        char op;
        cin >> op;
        if (op == 'U') {
            int p, v;
            cin >> p >> v;
            p--;
            seg.modify(p, {v, 0, 0});
        } else {
            int l, r, k;
            cin >> l >> r >> k;
            l--, r--;
            Info c = seg.rangeQuery(l, r + 1);
            if (k == 0) cout << c.lcm0 << '\n';
            else if (k == 1) cout << c.lcm1 << '\n';
            else cout << c.lcm2 << '\n';
        }
        
    }
    
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 10
12 10 16 28 15
Q 1 3 1
Q 3 4 0
Q 2 2 0
Q 2 5 2
U 3 21
Q 1 3 1
Q 2 4 1
Q 3 5 1
Q 4 4 0
Q 2 5 2

output:

4
4
10
20
6
14
21
28
210

result:

ok 9 lines

Test #2:

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

input:

20 10
12 15 17 13 18 11 17 9 13 13 8 9 6 18 2 20 6 8 10 16
Q 3 19 1
Q 4 15 2
Q 1 17 1
Q 13 14 0
Q 11 18 2
Q 1 16 2
Q 3 20 1
Q 5 20 1
Q 8 18 2
Q 13 15 1

output:

1
1
1
6
2
1
1
1
1
6

result:

ok 10 lines

Test #3:

score: 0
Accepted
time: 222ms
memory: 11952kb

input:

99417 100000
997410 720487 932768 115 128154 302401 999266 146789 236143 92360 396671 186303 387999 345639 669897 396857 935750 538939 846502 419289 313345 685374 524667 204499 443553 878316 229629 27394 534535 670619 914168 417399 457308 558816 430796 140419 939340 198147 778565 800925 716132 96848...

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 100000 lines

Test #4:

score: 0
Accepted
time: 203ms
memory: 11952kb

input:

99436 100000
185124 25933 931751 549787 947945 435421 484859 420463 320609 330410 154462 204695 699021 619411 119978 299723 485286 266888 632881 621274 818412 529262 683180 134611 498674 513694 586930 184482 719917 785513 258557 854168 546331 494349 407400 846753 177025 79664 969851 505360 297086 65...

output:

1
2
1
1
1
1
3
1
56300
1
12384699284
1
1337543592
161063
1
2
3
448477444200
1
44550
1
2
1
3
1
1
1
1
1
1
1
2
1
1
1
2
299267391095190
1
1
307267
3
803685
1
5
1
1
2
3
3
2
1
287211
1
655508
1
1
1
2
20
3
1
2
1
1
580803
1
1
4
835458
2
1
353019
1
1
1
2
30817594836
1
575704
215909
1
1
1
809644
1
1
1
2
1
1
1
...

result:

ok 100000 lines

Test #5:

score: 0
Accepted
time: 199ms
memory: 11952kb

input:

100000 100000
185124 25933 931751 549787 947945 435421 484859 420463 320609 330410 154462 204695 699021 619411 119978 299723 485286 266888 632881 621274 818412 529262 683180 134611 498674 513694 586930 184482 719917 785513 258557 854168 546331 494349 407400 846753 177025 79664 969851 505360 297086 6...

output:

2
2
1
2
1
3
1
1
728441
1
75032825160
1
62521619383862340
1
2
1
1
1
1
1
1
1
1
61512528819
1
125341410605929740
1
9
1
1
964890
1
2
74020
1
1
1
1
2
758166
1
1
1
1
858585
2666536944364800
1
340525
1
2
1
1
1
1
1
2
1
1
191665267830
503005
281993
45
3
2
17096779026
1
1
3
1
1
583882
1
1
1
1
1
1
1
1
1
1
7974...

result:

ok 100000 lines

Test #6:

score: 0
Accepted
time: 208ms
memory: 11864kb

input:

99772 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 9776...

output:

2
2
2
2
426
382
2
34
5882
2
2
2
2
2
2
2
479302
842
158
382
2
2
2
2
2
2
2
2
2
2
158
2
2
2
2
2
142
175222
1306
2
1574
2
2
2
554
2
2
6
2
2
2
2
2
13694
2
2
556154
2
64786
2
2
74
86
2
2
202
2
2
2
2
2
2
422338
2
479326
2
218
2
2
2
2
2
2
2
762946
2
197342
2
2
2
333182
2
762946
2
454042
93458
2
2
1354
2
2
4...

result:

ok 100000 lines

Test #7:

score: 0
Accepted
time: 197ms
memory: 12020kb

input:

99772 100000
799728 156672 461820 979236 278580 686628 736920 456348 738312 340620 47100 592356 891840 982524 929844 585996 695892 976536 798492 182172 566772 136008 86376 587796 535200 737472 409500 992256 648276 520632 432972 536376 664608 777468 658032 297624 254232 379464 537852 374196 842484 22...

output:

12
12
12
12
12
12
12
12
12
12
12
12
12
12
24204
12
12
12
3972
45516
12
12
12
12
12
12
12
12756
12
12
12
4596
1572
12
13116
12
12
12
12
13164
12
12
28092
12
12
12
12
38244
12
12
12
12
12
12
12
39612
4764
12
12
12
12
12
12
12
12
12
50628
12
15468
12
508812
12
12
12
12
12
12
12
17412
12
12
12
14172
12
...

result:

ok 100000 lines

Test #8:

score: 0
Accepted
time: 204ms
memory: 11952kb

input:

99772 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 9776...

output:

2
2
2
2
426
382
2
34
5882
2
2
2
2
2
2
2
479302
842
158
382
2
2
2
2
2
2
2
2
2
2
158
2
2
2
2
2
142
175222
1306
2
1574
2
2
2
554
2
2
6
2
2
2
2
2
13694
2
2
556154
2
64786
2
2
74
86
2
2
202
2
2
2
2
2
2
422338
2
479326
2
218
2
2
2
2
2
2
2
762946
2
197342
2
2
2
333182
2
762946
2
454042
93458
2
2
1354
2
2
4...

result:

ok 100000 lines

Test #9:

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

input:

99772 100000
799728 156672 461820 979236 278580 686628 736920 456348 738312 340620 47100 592356 891840 982524 929844 585996 695892 976536 798492 182172 566772 136008 86376 587796 535200 737472 409500 992256 648276 520632 432972 536376 664608 777468 658032 297624 254232 379464 537852 374196 842484 22...

output:

12
12
12
12
12
12
12
12
12
12
12
12
12
12
24204
12
12
12
3972
45516
12
12
12
12
12
12
12
12756
12
12
12
4596
1572
12
13116
12
12
12
12
13164
12
12
28092
12
12
12
12
38244
12
12
12
12
12
12
12
39612
4764
12
12
12
12
12
12
12
12
12
50628
12
15468
12
508812
12
12
12
12
12
12
12
17412
12
12
12
14172
12
...

result:

ok 100000 lines

Test #10:

score: 0
Accepted
time: 207ms
memory: 12056kb

input:

100000 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 977...

output:

218
2
2
2
2
2
2
2
762946
2
197342
2
2
2
333182
2
762946
2
454042
93458
2
2
1354
2
2
4354
2
2
2558
2
1574
2
526
1018
2
226
2
2
2
118
2
2
2
2
2
2
2
2
2
626
153946
2
93458
2
2
794
11546
2
158
2
1322
118
2
2
2
2
982
122
2
158
2
146294
502
2
2
2
838
22618
2
1018
2
2
2
2
53926
2
2
458
2
2
2
2
2
2
2
2
2
85...

result:

ok 100000 lines

Test #11:

score: 0
Accepted
time: 219ms
memory: 11884kb

input:

99417 100000
997410 720487 932768 115 128154 302401 999266 146789 236143 92360 396671 186303 387999 345639 669897 396857 935750 538939 846502 419289 313345 685374 524667 204499 443553 878316 229629 27394 534535 670619 914168 417399 457308 558816 430796 140419 939340 198147 778565 800925 716132 96848...

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 49799 lines

Test #12:

score: 0
Accepted
time: 208ms
memory: 12128kb

input:

99436 100000
185124 25933 931751 549787 947945 435421 484859 420463 320609 330410 154462 204695 699021 619411 119978 299723 485286 266888 632881 621274 818412 529262 683180 134611 498674 513694 586930 184482 719917 785513 258557 854168 546331 494349 407400 846753 177025 79664 969851 505360 297086 65...

output:

6
258
12384699284
344018
1
44550
13848458974641174
1
1
1
4572790943490
299267391095190
6
8636785118672876
2
34
1
1
2
1
1
544978
853362
1
1
1
1
1
4
1
513598
332181952920
1
903676
12
13914317985
1
502144
1
1
1
1
1
2
120148896790
890966
2044698528
816600
2
147307
500355991408
1
1
1
1
453027
5866
2
3719...

result:

ok 50057 lines

Test #13:

score: 0
Accepted
time: 202ms
memory: 12148kb

input:

100000 100000
185124 25933 931751 549787 947945 435421 484859 420463 320609 330410 154462 204695 699021 619411 119978 299723 485286 266888 632881 621274 818412 529262 683180 134611 498674 513694 586930 184482 719917 785513 258557 854168 546331 494349 407400 846753 177025 79664 969851 505360 297086 6...

output:

785467
573087
1
1
1
62521619383862340
514727
1
1
3
1
9
2
65
2
3
11235114372
1
1
1
340525
650875
120364
1
110908477869339818
1
2
1
1
3
1
62
1
1
1
1
2
1
351012042060
101201
8
2
59212
1
12
2
1
4
2
1
410187570878
573546
4
1
749198
1
1
1
1
1
173112341009520
2
1
529205718520040784
2
1
173566
984723
1
1
1
...

result:

ok 50064 lines

Test #14:

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

input:

99772 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 9776...

output:

2
2
2
2
2
158
2
2
2
2
2
2
2
74
2
2
2
2
2
2
2
2
2
2
2
401266
2
746
2
218
326
1
1
166
2
2
14
2
2
2
22
2
122
2
2
2
158
2
1094
2
2
32482
394
626
2
2
1
994078
1286
2
2
2
2
2
2
2
2
2
2
2
194
2
2
1
1
2
2
1154
2
1
2234
866
778
2
866
2
2
662
2
2
1
554
1
2
2
2
2
1
2
1
1
1
746
2
2
2
2
1
2
580462
2
2
687998
758...

result:

ok 49936 lines

Test #15:

score: 0
Accepted
time: 215ms
memory: 11900kb

input:

99772 100000
799728 156672 461820 979236 278580 686628 736920 456348 738312 340620 47100 592356 891840 982524 929844 585996 695892 976536 798492 182172 566772 136008 86376 587796 535200 737472 409500 992256 648276 520632 432972 536376 664608 777468 658032 297624 254232 379464 537852 374196 842484 22...

output:

28572
12
12
12
12
12
12
12
12
12
2724
12
12
12
12
12
45852
12
12
12
12
12
12
12
12
3396
4
12
12
50628
12
12
12
12
12
12
12
12
3156
12
14052
12
12
12
94596
12
12
12
12
12
12
12
5196
12
12
12
12
8868
12
12
12
12
12
12
12
12
12
31404
12
12
11796
12
12
12
276996
12
5484
12
12
12
12
12
12
12
12
12
12
12
...

result:

ok 50076 lines

Test #16:

score: 0
Accepted
time: 205ms
memory: 12108kb

input:

99772 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 9776...

output:

2
2
2
2
2
158
2
2
2
2
2
2
2
74
2
2
2
2
2
2
2
2
2
2
2
401266
2
746
2
218
326
1
1
166
2
2
14
2
2
2
22
2
122
2
2
2
158
2
1094
2
2
32482
394
626
2
2
1
994078
1286
2
2
2
2
2
2
2
2
2
2
2
194
2
2
1
1
2
2
1154
2
1
2234
866
778
2
866
2
2
662
2
2
1
554
1
2
2
2
2
1
2
1
1
1
746
2
2
2
2
1
2
580462
2
2
687998
758...

result:

ok 49936 lines

Test #17:

score: 0
Accepted
time: 213ms
memory: 12036kb

input:

99772 100000
799728 156672 461820 979236 278580 686628 736920 456348 738312 340620 47100 592356 891840 982524 929844 585996 695892 976536 798492 182172 566772 136008 86376 587796 535200 737472 409500 992256 648276 520632 432972 536376 664608 777468 658032 297624 254232 379464 537852 374196 842484 22...

output:

28572
12
12
12
12
12
12
12
12
12
2724
12
12
12
12
12
45852
12
12
12
12
12
12
12
12
3396
4
12
12
50628
12
12
12
12
12
12
12
12
3156
12
14052
12
12
12
94596
12
12
12
12
12
12
12
5196
12
12
12
12
8868
12
12
12
12
12
12
12
12
12
31404
12
12
11796
12
12
12
276996
12
5484
12
12
12
12
12
12
12
12
12
12
12
...

result:

ok 50076 lines

Test #18:

score: 0
Accepted
time: 210ms
memory: 12076kb

input:

100000 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 977...

output:

2
2
2
166
2
2
14
2
2
2
22
2
122
2
2
2
158
2
1094
2
2
32482
394
626
2
2
2
994078
1286
2
2
2
2
2
2
2
2
2
2
118
194
2
2
2
2
2
2
1154
2
1
64786
866
778
2
866
2
2
662
2
2
2
554
2
2
1202
2
2
2
2
1
82
2
746
2
2
2
538
1
2
580462
2
2
687998
758
2
2
1
34946
1
756526
2
123542
2
718
2
2
2
2
2
6
2
2
3398
599798
...

result:

ok 49940 lines

Test #19:

score: 0
Accepted
time: 197ms
memory: 12152kb

input:

99772 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 9776...

output:

2
2
2
2
2
158
2
2
2
2
2
2
2
74
1306
2
2
2
2
2
2
2
2
2
2
401266
2
746
2
218
326
82
2
166
2
2
14
2
2
2
22
2
122
2
2
2
158
2
1094
2
2
32482
394
626
2
2
2
994078
1286
2
2
2
2
2
2
2
2
2
2
118
194
2
2
2
2
2
2
1154
2
2
64786
866
778
2
866
2
2
662
2
2
2
554
2
2
2
626
2
2
2
2
82
2
746
2
922
2
538
2
2
580462
...

result:

ok 49928 lines

Test #20:

score: 0
Accepted
time: 194ms
memory: 11900kb

input:

99772 100000
799728 156672 461820 979236 278580 686628 736920 456348 738312 340620 47100 592356 891840 982524 929844 585996 695892 976536 798492 182172 566772 136008 86376 587796 535200 737472 409500 992256 648276 520632 432972 536376 664608 777468 658032 297624 254232 379464 537852 374196 842484 22...

output:

28572
12
12
12
12
12
12
12
12
12
2724
12
12
12
12
12
45852
12
12
12
12
12
12
12
12
3396
12
12
12
50628
12
12
12
12
12
12
12
12
3156
12
14052
12
12
12
94596
12
12
12
12
12
12
12
5196
12
12
12
12
8868
12
12
12
12
12
12
12
12
12
31404
12
12
11796
12
12
12
276996
12
5484
12
12
12
12
12
12
12
12
12
12
12...

result:

ok 50082 lines

Test #21:

score: 0
Accepted
time: 199ms
memory: 11900kb

input:

99772 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 9776...

output:

2
2
2
2
2
158
2
2
2
2
2
2
2
74
1306
2
2
2
2
2
2
2
2
2
2
401266
2
746
2
218
326
82
2
166
2
2
14
2
2
2
22
2
122
2
2
2
158
2
1094
2
2
32482
394
626
2
2
2
994078
1286
2
2
2
2
2
2
2
2
2
2
118
194
2
2
2
2
2
2
1154
2
2
64786
866
778
2
866
2
2
662
2
2
2
554
2
2
2
626
2
2
2
2
82
2
746
2
922
2
538
2
2
580462
...

result:

ok 49928 lines

Test #22:

score: 0
Accepted
time: 199ms
memory: 11960kb

input:

99772 100000
799728 156672 461820 979236 278580 686628 736920 456348 738312 340620 47100 592356 891840 982524 929844 585996 695892 976536 798492 182172 566772 136008 86376 587796 535200 737472 409500 992256 648276 520632 432972 536376 664608 777468 658032 297624 254232 379464 537852 374196 842484 22...

output:

28572
12
12
12
12
12
12
12
12
12
2724
12
12
12
12
12
45852
12
12
12
12
12
12
12
12
3396
12
12
12
50628
12
12
12
12
12
12
12
12
3156
12
14052
12
12
12
94596
12
12
12
12
12
12
12
5196
12
12
12
12
8868
12
12
12
12
12
12
12
12
12
31404
12
12
11796
12
12
12
276996
12
5484
12
12
12
12
12
12
12
12
12
12
12...

result:

ok 50082 lines

Test #23:

score: 0
Accepted
time: 196ms
memory: 12024kb

input:

100000 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 977...

output:

2
2
2
166
2
2
14
2
2
2
22
2
122
2
2
2
158
2
1094
2
2
32482
394
626
2
2
2
994078
1286
2
2
2
2
2
2
2
2
2
2
118
194
2
2
2
2
2
2
1154
2
2
64786
866
778
2
866
2
2
662
2
2
2
554
2
2
1202
626
2
2
2
2
82
2
746
2
922
2
538
2
2
580462
2
2
687998
758
2
146
2
34946
2
756526
2
123542
2
718
2
2
2
2
2
6
2
2
3398
5...

result:

ok 49932 lines

Test #24:

score: 0
Accepted
time: 202ms
memory: 11924kb

input:

99772 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 9776...

output:

2
34
2
643718
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1306
2
2
2
1
2
2
2
1
2
746
2
2
2
2
2
2
166
2
458
2
2
2
22
2
122
2
2
2
226
13462
2
2
2
2
46
1
2
2
2
554
2
794
2
1018
2
2
118
458
2
2
1762
2
5744
2
2
2
2
866
2026
2
2
866
2
2
662
2
2
1
2
2
1642
2
1
2
2
450962
11842
698
2
28542
2
2
283282
326
825262
2
2
2
2...

result:

ok 49730 lines

Test #25:

score: 0
Accepted
time: 213ms
memory: 11892kb

input:

99772 100000
799728 156672 461820 979236 278580 686628 736920 456348 738312 340620 47100 592356 891840 982524 929844 585996 695892 976536 798492 182172 566772 136008 86376 587796 535200 737472 409500 992256 648276 520632 432972 536376 664608 777468 658032 297624 254232 379464 537852 374196 842484 22...

output:

12
5172
12
12
12
12
45516
12
12
2388
24
4596
12
45852
12
12
12
12
38244
12
39612
12
12
12
12
12
25332
17124
12
12
12
12
1788
12
12
14052
12
12
12
20652
12
12
945960
12
12
5196
12
12
12
12
17868
12
12
12
12
12
12
12
12
12
31404
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
353172
40116
12
12
...

result:

ok 50113 lines

Test #26:

score: 0
Accepted
time: 207ms
memory: 12028kb

input:

99772 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 9776...

output:

2
34
2
643718
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1306
2
2
2
1
2
2
2
1
2
746
2
2
2
2
2
2
166
2
458
2
2
2
22
2
122
2
2
2
226
13462
2
2
2
2
46
1
2
2
2
554
2
794
2
1018
2
2
118
458
2
2
1762
2
5744
2
2
2
2
866
2026
2
2
866
2
2
662
2
2
1
2
2
1642
2
1
2
2
450962
11842
698
2
28542
2
2
283282
326
825262
2
2
2
2...

result:

ok 49730 lines

Test #27:

score: 0
Accepted
time: 211ms
memory: 11880kb

input:

99772 100000
799728 156672 461820 979236 278580 686628 736920 456348 738312 340620 47100 592356 891840 982524 929844 585996 695892 976536 798492 182172 566772 136008 86376 587796 535200 737472 409500 992256 648276 520632 432972 536376 664608 777468 658032 297624 254232 379464 537852 374196 842484 22...

output:

12
5172
12
12
12
12
45516
12
12
2388
24
4596
12
45852
12
12
12
12
38244
12
39612
12
12
12
12
12
25332
17124
12
12
12
12
1788
12
12
14052
12
12
12
20652
12
12
945960
12
12
5196
12
12
12
12
17868
12
12
12
12
12
12
12
12
12
31404
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
353172
40116
12
12
...

result:

ok 50113 lines

Test #28:

score: 0
Accepted
time: 204ms
memory: 11904kb

input:

100000 100000
67522 810426 959176 794398 778802 983478 906982 988840 251298 912378 503494 597514 743684 917932 210788 629856 167446 484766 327640 762840 630602 310996 405312 427858 101598 68298 227192 8948 127810 811452 414984 812970 345514 105980 767572 810146 942472 555648 125578 515618 124202 977...

output:

2
2
2
2
2
166
2
458
2
2
2
22
2
122
2
2
2
226
13462
2
2
2
2
46
2
2
2
2
554
2
794
2
1018
2
2
118
458
2
2
1762
2
1436
2
2
2
2
866
2026
2
2
866
2
2
662
2
2
2
2
2
1642
2
1
2
2
450962
11842
698
2
28542
2
2
283282
326
825262
2
2
2
2
1844
2
2
1
2
2
2
2
6
2
2
2
1838
2
1286
1354
2
2
2
2
1
1
2
1
93458
1
2
2
2
...

result:

ok 49705 lines