QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709977#6405. Barkleytassei903#TL 916ms47336kbC++233.6kb2024-11-04 17:44:062024-11-04 17:44:07

Judging History

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

  • [2024-11-04 17:44:07]
  • 评测
  • 测评结果:TL
  • 用时:916ms
  • 内存:47336kb
  • [2024-11-04 17:44:06]
  • 提交

answer


#include <bits/stdc++.h>
#include <bits/extc++.h> 
using namespace std;
#define sz(x) (int)(x).size()
#define rep(i, l, r) for (int i = l; i < (r); i++)
#define rrep(i, l, r) for(int i = (int)(r)-1; i >= (int)(l); i--)
#define all(x) begin(x), end(x)

using ll = long long;
using vi = vector<int>;

using pii = pair<int, int>;


template <class S, S (*op)(S, S), S (*e)()> struct segtree {
  private:
    int n;
    int size;
    vector<S> data;

    void update(int i) {
        data[i] = op(data[2 * i], data[2 * i + 1]);
    }

  public:
    segtree(int n) : segtree(vector<S>(n, e())) {}
    segtree(const vector<S> &v) : n((int)v.size()), size(1) {
        while (size < n) size *= 2;
        data = vector<S>(2 * size, e());
        rep(i, 0, n) {
            data[size + i] = v[i];
        }
        rrep(i, 1, size) update(i);
    }

    void set(int p, S x) {
        assert(0 <= p && p < n);
        p += size;
        data[p] = x;
        while (p > 1) {
            p >>= 1;
            update(p);
        }
    }

    S get(int p) {
        assert(0 <= p && p < n);
        return data[p + size];
    }

    S prod(int l, int r) {
        assert(0 <= l && l <= r && r <= n);
        S sml = e(), smr = e();
        l += size;
        r += size;
        while (l < r) {
            if (l & 1) sml = op(sml, data[l++]);
            if (r & 1) smr = op(data[--r], smr);
            l >>= 1;
            r >>= 1;
        }
        return op(sml, smr);
    }

    S all_prod() {
        return data[1];
    }

    template <class F> int max_right(int l, F f) {
        assert(0 <= l && l <= n);
        assert(f(e()));
        if (l == n) return n;
        l += size;
        S sm = e();
        do {
            while (l % 2 == 0) l >>= 1;
            if (!f(op(sm, data[l]))) {
                while (l < size) {
                    l = 2 * l;
                    if (f(op(sm, data[l]))) {
                        sm = op(sm, data[l]);
                        l++;
                    }
                }
                return l - size;
            }
            sm = op(sm, data[l]);
            l++;
        } while ((l & -l) != l);
        return n;
    }

};

using ull = unsigned long long;

ull gcd(ull a, ull b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ull e() {
    return 0;
}

int main() {
    int n, q;cin >> n >> q;
    vector<ull> a(n);rep(i, 0, n) cin >> a[i];

    segtree<ull, gcd, e> st(a);
    vector<vector<pair<int, ull>>> g(n);
    rep(i, 0, n) {
        ull now = a[i];
        int l = i;
        while (true) {
            int r = st.max_right(l, [&](ull x)->bool{if (now == 0)return x == 0;else return x % now == 0;});
            g[i].emplace_back(r, st.prod(i, r));
            // cout << i << " " << r << " " << st.prod(i, r) << endl;

            if (r == n)break;
            now = st.prod(i, r + 1);
        }
    }

    rep(_, 0, q) {
        int l, r, k;cin >> l >> r >> k;
        l--;
        auto dfs = [&](auto self, int x, int d, ull now) -> ull {
            // cout << x << " " << d << " " << now << endl;
            if (d == k && x >= r)return now;
            if (x >= r) return 0;
            if (d == k) return gcd(now, st.prod(x, r));
            ull ans = self(self, x+1, d+1, now);
            for (auto[y, gc] : g[x]) {
                ans = max(ans, self(self, y + 1, d + 1, gcd(now, gc)));
                if (y >= r) break;
            }
            return ans;
        };

        cout << dfs(dfs, l, 0, 0) << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4
3 2 6 4
1 3 1
2 4 1
1 4 2
1 4 3

output:

3
2
3
6

result:

ok 4 number(s): "3 2 3 6"

Test #2:

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

input:

100 10000
7 25 33 17 13 33 24 29 11 1 3 19 2 20 33 23 14 24 15 12 3 1 5 13 6 35 15 21 10 34 31 19 7 33 17 26 26 1 19 21 31 5 29 20 18 32 19 18 19 31 11 26 6 19 2 26 23 1 4 2 31 21 29 30 1 14 20 23 14 32 4 34 13 29 5 26 24 29 28 5 26 26 21 19 2 33 2 31 30 3 23 24 26 32 36 21 21 11 5 9
56 57 1
90 97 1...

output:

26
1
1
1
1
1
1
1
31
1
1
1
1
1
26
1
1
1
1
1
1
29
1
1
1
1
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
1
1
1
21
1
1
1
1
1
19
1
1
1
21
1
1
1
1
1
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
4
1
1
1
1
1
3
1
2
1
26
1
1
1
1
1
1
1
7
1
1
1
33
1
1
1
1
1
1
2
1
26
1
1
1
2
1
1
1
1
1
1
26
1
1
1
1
31
1
1
2
1
4
29
1
2
1
1...

result:

ok 10000 numbers

Test #3:

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

input:

1000 66666
25 21 18 19 9 34 16 7 36 2 8 10 25 15 34 9 1 34 6 19 20 20 1 16 10 6 10 1 30 34 6 15 15 11 9 4 34 36 27 17 2 2 19 10 4 22 15 16 22 36 27 26 20 23 29 16 27 14 3 31 32 16 5 5 31 13 27 5 17 23 20 19 13 22 30 14 25 13 7 16 10 6 1 6 3 5 36 1 33 22 31 26 28 3 14 14 2 31 35 7 19 30 36 5 3 14 14 ...

output:

1
2
1
1
1
1
1
1
1
1
1
3
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
17
1
1
1
20
1
1
1
7
1
1
1
1
1
1
1
1
3
1
1
1
1
1
1
7
1
2
15
1
3
1
2
1
1
3
4
1
1
1
1
1
31
1
1
1
2
1
1
1
1
27
3
1
1
1
1
4
10
1
1
1
1
17
1
1
1
2
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
8
1
1
17
1
2
1
1
1
30
1
25
1
35
1...

result:

ok 66666 numbers

Test #4:

score: 0
Accepted
time: 55ms
memory: 4192kb

input:

10000 66666
35 30 29 34 3 25 23 29 30 32 34 1 25 1 23 11 10 24 33 25 14 1 16 25 33 5 19 2 16 1 19 14 34 6 26 25 36 35 1 32 35 27 18 3 7 16 10 25 6 21 36 31 24 17 20 12 30 21 25 31 27 22 5 19 6 16 7 26 15 21 32 11 34 4 7 25 34 3 14 13 10 1 28 8 12 24 34 27 17 8 17 32 23 30 23 8 19 22 2 11 23 10 4 30 ...

output:

1
16
2
2
1
23
1
1
1
2
1
3
5
1
1
2
1
1
1
1
30
1
1
1
3
18
1
1
1
1
2
1
1
1
1
1
1
1
1
2
2
1
6
36
1
1
2
19
2
1
1
1
1
1
2
1
1
1
21
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
1
29
1
1
30
2
2
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
2
1
1
1
2
29
1
1
14
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
2
3
1
9
5
1
2
2
1
32
1
1
1
3
2
1
1
...

result:

ok 66666 numbers

Test #5:

score: 0
Accepted
time: 92ms
memory: 13860kb

input:

100000 66666
7 27 21 15 35 19 32 8 1 30 6 3 33 29 25 5 1 24 34 9 13 27 9 32 20 26 5 10 1 30 29 15 11 31 12 27 10 32 14 30 27 6 16 17 16 36 12 35 18 4 14 9 12 33 1 10 27 31 16 27 16 15 6 16 28 16 26 6 25 23 23 31 22 16 30 33 15 2 27 11 18 23 3 2 23 2 13 17 21 15 4 2 19 22 35 35 13 28 9 30 20 29 17 5 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
2
1
1
7
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
29
1
1
1
1
1
1
1
1
1
1
1
35
3
1
1
20
1
1
1
1
1
1
1
1
1
2
1
1
2
1
1
19
1
1
1
1
1
1
1
1
1
1
1
1
1
1
25
1
1
1
1
1
1
2
13
1
9
25
1
1
1
1
1
1
1
1
2
1
1
1
25
1
18
4
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
23
1
1
1
1
1
33
2...

result:

ok 66666 numbers

Test #6:

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

input:

100000 66666
450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 450283905890997363 45...

output:

450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997363
450283905890997...

result:

ok 66666 numbers

Test #7:

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

input:

100000 66666
701982420492091392 592297667290202112 789730223053602816 369768517790072832 526486815369068544 562220051373121536 701982420492091392 701982420492091392 444223250467651584 592297667290202112 554652776685109248 888446500935303168 623984373770747904 888446500935303168 888446500935303168 55...

output:

9795520512
9795520512
352638738432
9795520512
29386561536
39182082048
117546246144
9795520512
19591041024
9795520512
29386561536
352638738432
176319369216
9795520512
9795520512
58773123072
176319369216
29386561536
9795520512
9795520512
117546246144
29386561536
9795520512
58773123072
117546246144
117...

result:

ok 66666 numbers

Test #8:

score: 0
Accepted
time: 388ms
memory: 28276kb

input:

100000 66666
592297667290202112 623984373770747904 789730223053602816 789730223053602816 789730223053602816 444223250467651584 592297667290202112 554652776685109248 666334875701477376 623984373770747904 888446500935303168 592297667290202112 350991210246045696 789730223053602816 888446500935303168 39...

output:

58773123072
352638738432
705277476864
33853318889472
176319369216
176319369216
313456656384
12694994583552
117546246144
528958107648
1410554953728
4231664861184
528958107648
19042491875328
39182082048
19042491875328
39182082048
3173748645888
528958107648
705277476864
352638738432
4231664861184
17631...

result:

ok 66666 numbers

Test #9:

score: 0
Accepted
time: 243ms
memory: 20620kb

input:

100000 66666
394865111526801408 467988280328060928 888446500935303168 592297667290202112 394865111526801408 394865111526801408 789730223053602816 623984373770747904 932600926626323251 562220051373121536 415989582513831936 267489760325645039 467988280328060928 592297667290202112 789730223053602816 44...

output:

304679870005248
1371059415023616
5484237660094464
824837199746271719
854723856817756836
879549815483199491
152339935002624
3656158440062976
270826551115776
58498535041007616
417942208512
623984373770747904
304679870005248
101559956668416
444223250467651584
914039610015744
685529707511808
88844650093...

result:

ok 66666 numbers

Test #10:

score: 0
Accepted
time: 168ms
memory: 13300kb

input:

100000 66666
298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 298023223876953125 29...

output:

298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953125
298023223876953...

result:

ok 66666 numbers

Test #11:

score: 0
Accepted
time: 602ms
memory: 32492kb

input:

100000 66666
472925401611328125 437893890380859375 375423431396484375 405457305908203125 437893890380859375 788209002685546875 262736334228515625 283755240966796875 262736334228515625 625705718994140625 510759433740234375 472925401611328125 437893890380859375 405457305908203125 472925401611328125 72...

output:

18984375
12814453125
854296875
18984375
2562890625
18984375
21357421875
18984375
18984375
284765625
4271484375
18984375
18984375
284765625
4271484375
18984375
854296875
854296875
474609375
4271484375
12814453125
18984375
854296875
18984375
284765625
94921875
94921875
18984375
18984375
854296875
1423...

result:

ok 66666 numbers

Test #12:

score: 0
Accepted
time: 497ms
memory: 30988kb

input:

100000 66666
339211709033203125 284937835587890625 781869420853171875 930796929587109375 284937835587890625 610581076259765625 615606434912109375 726882233642578125 563074685799609375 603156410372446875 472982736071671875 664854949705078125 927046162700476875 434371900473984375 615606434912109375 72...

output:

826875
385875
2701125
8103375
1157625
2701125
1157625
77175
2701125
8575
77175
4254271875
385875
13505625
53603825625
40516875
1418090625
8103375
202584375
4862025
102102525
77175
231525
77175
1620675
8103375
121550625
4862025
4501875
5955980625
2701125
283618125
46903347421875
89339709375
425427187...

result:

ok 66666 numbers

Test #13:

score: 0
Accepted
time: 285ms
memory: 22380kb

input:

100000 66666
768867187500000000 531441000000000000 410062500000000000 464724384570141087 787320000000000000 896283049339348985 476062296883200000 590490000000000000 205031250000000000 656100000000000000 510183360000000000 768867187500000000 566870400000000000 717445350000000000 498225937500000000 62...

output:

131220000000000
43740000000
27337500000
531441000000000
1093500000000
273375000000
524880000000
265720500000000
262440000000
13668750000
11809800000000
590490000000000
656100000000
24603750000000
151875000000
109350000000
377913600000
398580750000000
82012500000000
1640250000000
397627607007569321
1...

result:

ok 66666 numbers

Test #14:

score: 0
Accepted
time: 216ms
memory: 13932kb

input:

100000 66666
576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 576460752303423488 57...

output:

576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423488
576460752303423...

result:

ok 66666 numbers

Test #15:

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

input:

100000 66666
437718434374464997 437718434374464997 195739344661245593 437718434374464997 255966835326244237 149683028270364277 334725861580473233 75295356187869701 748524423279410557 195739344661245593 334725861580473233 255966835326244237 334725861580473233 572401029566608073 334725861580473233 437...

output:

3757
48841
48841
830297
48841
634933
63869
3757
3757
48841
3757
830297
48841
48841
3757
3757
830297
48841
48841
3757
3757
8254129
48841
3757
10793861
3757
48841
3757
3757
2385443281
3757
3757
48841
140320193
14115049
48841
48841
3757
48841
3757
3757
3757
48841
10793861
48841
48841
48841
48841
3757
8...

result:

ok 66666 numbers

Test #16:

score: 0
Accepted
time: 394ms
memory: 24236kb

input:

100000 66666
45353206897101877 235495977390733981 27509322216274909 640088043733324429 34264426936753621 640088043733324429 142841822351756677 388250124887426293 148095408462214153 17299676857657417 17299676857657417 402529594512709177 17299676857657417 640088043733324429 388250124887426293 56490001...

output:

5917
13354669
97
61
37
1
61
97
1
97
3589
97
1
3589
97
97
1
5917
97
3589
5917
97
5917
97
47929907041
1
4649200982977
1
1
218929
97
97
1
1
1
218929
37
226981
61
2257
1
1
1
1
1
218929
1
97
13354669
2923724329501
912673
1
97
1
1
3589
61
61
218929
5917
4649200982977
1
5917
97
2257
5917
61
5917
1
5917
591...

result:

ok 66666 numbers

Test #17:

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

input:

100000 66666
31378474310796875 66522365538889375 794305606422029988 363314846854706909 25320923395296875 126604616976484375 126685643931349325 298786896064503125 56489143751177548 705137074712227375 784963913358894625 268401787990146875 31378474310796875 156992782671778925 25337128786269865 69263565...

output:

43918715
2884548055
165731
4254708381125
2388766358046875
4143275
1325
184493
800588548081391855
244453225
64780104625
884553481638582020
5064184679059375
219593575
800174948855018885
219593575
14045
922465
370029178193359375
64780104625
828655
184493
987328382667665993
4143275
80277516625
784963913...

result:

ok 66666 numbers

Test #18:

score: 0
Accepted
time: 265ms
memory: 18480kb

input:

100000 66666
338134100426929 519288679363117 797496413920441 606065523119263 444936598813303 519288679363117 248237576380249 519288679363117 795104957145937547 248237576380249 381230296039477 289719846716611 797496413920441 519288679363117 930763755299299 338134100426929 188650674737407 338134100426...

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 66666 numbers

Test #19:

score: 0
Accepted
time: 301ms
memory: 20692kb

input:

100000 66666
1053716702538473 41275846970251687 41275846970251687 177149557812239 1053716702538473 1053716702538473 177149557812239 41275846970251687 1053716702538473 245515991691464209 1053716702538473 1053716702538473 160005726539569 41275846970251687 245515991691464209 1053716702538473 4127584697...

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
9127
1
9127
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
9127
1
1
1
1
9127
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
9127
1
1
1
1
1
9127
...

result:

ok 66666 numbers

Test #20:

score: 0
Accepted
time: 294ms
memory: 20212kb

input:

100000 66666
41655640594789601 41655640594789601 41655640594789601 41655640594789601 100721707609683701 41655640594789601 100721707609683701 100721707609683701 100721707609683701 243541144463387801 41655640594789601 100721707609683701 41655640594789601 17227591097705501 41655640594789601 10072170760...

output:

1
1
3581
1
1
1481
3581
1481
5303461
5303461
1
1
1
1
3581
1
1481
3581
1
1
1
1
5303461
1
1
1481
1
1
1481
5303461
1
1
1
1
1481
1
1
1
1
1
1
1
1
1481
1
3581
1
1
1
1
1
1
1
1
1
1
1481
5303461
1
5303461
1
1
5303461
1
1
1
5303461
2193361
1
1
1
3581
1481
1
2193361
1
1
1
1
1
1
1
1
1
1
1
1
1
5303461
5303461
148...

result:

ok 66666 numbers

Test #21:

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

input:

100000 66666
977142648636961 977142648636961 977142648636961 977142648636961 977142648636961 977142648636961 72824662358594073 977142648636961 977142648636961 977142648636961 977142648636961 977142648636961 977142648636961 977142648636961 977142648636961 977142648636961 977142648636961 9771426486369...

output:

977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
977142648636961
320578543307887433
977142648636961
982461370523776742
977142648636961
977142648636961
977142...

result:

ok 66666 numbers

Test #22:

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

input:

100000 66666
39302646579895813 92257280832229991 92257280832229991 38805014811590903 38313683824489693 92257280832229991 93440379306034261 93440379306034261 38805014811590903 94638649720590431 93440379306034261 91089162199144621 38313683824489693 38805014811590903 16322063266379399 16115400918867469...

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 66666 numbers

Test #23:

score: 0
Accepted
time: 248ms
memory: 16088kb

input:

100000 66666
18986649113634949 149417824264164721 18986649113634949 2412649537226281 18986649113634949 306577414194589 2412649537226281 2412649537226281 18986649113634949 2412649537226281 149417824264164721 2412649537226281 2412649537226281 18986649113634949 2412649537226281 2412649537226281 3065774...

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 66666 numbers

Test #24:

score: 0
Accepted
time: 239ms
memory: 16052kb

input:

100000 66666
523941011210103901 523941011210103901 927478369620543313 295979067781577977 523941011210103901 295979067781577977 523941011210103901 167201281614739429 295979067781577977 523941011210103901 523941011210103901 927478369620543313 927478369620543313 167201281614739429 927478369620543313 16...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
550909
1
1
1
537255822253
1
1
975217
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
975217
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
752045370831378182
1
1
1
1
1
1
1
1
1
1
1
1
1
537255822253
975217
1
1
1
1
975217
...

result:

ok 66666 numbers

Test #25:

score: 0
Accepted
time: 169ms
memory: 15196kb

input:

100000 66666
119336946756580697 21407447765136011 3840209023880993 142689178022006377 99806495899686217 17903946813319771 99806495899686217 621161893216905093 823684604342419 142689178022006377 21407447765136011 99806495899686217 17903946813319771 21407447765136011 21407447765136011 3840209023880993...

output:

522553
93739
1
853776535995198818
93739
1
478300669305073451
151605490118300919
1
1
522553
1
1
1
522553
809559597344142227
1
1
93739
190997843089
93739
648193084672583815
1
1
1
40967036387
1
522553
1
119336946756580697
1
1
1
335265327363373768
1
1
99806495899686217
93739
1
1
1
1
1
1
228372905249
1
4...

result:

ok 66666 numbers

Test #26:

score: 0
Accepted
time: 799ms
memory: 47336kb

input:

100000 66666
12600 320892 5353920 1290240 5483520 24806400 7920640 9175040 34546176 1146880 38535168 260112384 132710400 3371335680 6955597824 644087808 4128768000 33973862400 2179989504 84557168640 66303557632 52781121536 434865438720 642634481664 1449551462400 7187359334400 1855425871872 460812409...

output:

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

result:

ok 66666 numbers

Test #27:

score: 0
Accepted
time: 730ms
memory: 46028kb

input:

100000 66666
129200 677376 8400 707616 984960 64512 3686400 7879680 14745600 716513280 119848960 61931520 466944000 153354240 2913730560 14863564800 807403520 8925478912 39118700544 234712203264 635311226880 45298483200 1162661068800 646862340096 516402708480 841813590016 33661806182400 782757789696...

output:

4
2
2
2
2
4
2
4
1
4
2
2
4
4
2
2
2
4
268435456
4
4
2
2
2
2
4
2
2
2
1
2
2
2
2
4
2
8
4
2
2
1
1
1
2
2
1
2
2
4
2
2
2
4
1
4
2
4
2
2
16
4
4
1
2
2
4
2
2
2
4
2
2
2
2
2
2
8
4
1
4
2
8
2
4
2
2
16
4
4
2
1
16
4
4
2
1
2
2
2
2
2
2
16
1
2
1
4
1
16
2
32
1
4
8
8
2
4
4
1
1
1
2
2
2
2
2
32
4
2
2
2
2
2
8
2
2
2
2
1
2
2
16
...

result:

ok 66666 numbers

Test #28:

score: 0
Accepted
time: 535ms
memory: 37964kb

input:

100000 66666
59850 6720 109440 12403200 13440 614400 9139200 716800 40857600 171601920 453246976 7667712 53084160 1120665600 12582912 190716211864194797 377487360 1585446912 24914165760 83969966080 21139292160 70128762880 110578630656 34225520640 4177124130816 16234976378880 33919504220160 901943132...

output:

8
268435456
4
16
4
16
16384
4
8
4
8
96
16
4
4
2199023255552
256
4398046511104
36028797018963968
8
2
1024
16
256
4
8
128
262144
9007199254740992
68719476736
17179869184
4
262144
512
8
536870912
131072
268435456
16
4
1
1073741824
8
4
16
4
2
134217728
32
32
8
8
2
8
16
16
4
4
16
8
16
2
16777216
17179869...

result:

ok 66666 numbers

Test #29:

score: 0
Accepted
time: 242ms
memory: 21556kb

input:

100000 66666
16320 465920 4608 330480 4202496 614400 10886400 226492416 18264064 982333440 98058240 44564480 555089920 86507520 792723456 1804861440 32487505920 30198988800 192367558656 24914165760 889435717632 471104225280 1848178114560 124570828800 27058293964800 34321321355118415 17797270732800 4...

output:

16
533874399602908432
33554432
384
512
4503599627370496
33554432
17592186044416
9007199254740992
4194304
33554432
8589934592
4503599627370496
70368744177664
17179869184
2097152
8
1024
268435456
33554432
8
72057594037927936
18014398509481984
857414636395720789
3092376453120
262144
5308416
28147497671...

result:

ok 66666 numbers

Test #30:

score: 0
Accepted
time: 252ms
memory: 20868kb

input:

100000 66666
702345691905 934867260198872280 1668603098344 211680 4164496808472 296783257205991200 2118689870000 32400 504787491936 901479143763198270 1983093718320 77440 212177160072 140230089029830842 7334519113600 68040 2797364017812 120197219168426436 1739020645296 36465 1067819694480 7345385615...

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 66666 numbers

Test #31:

score: 0
Accepted
time: 240ms
memory: 20796kb

input:

100000 66666
286023132450 740103247657440555 1223138922768 233928 404477157000 289363675775841420 2283562463520 9600 155319228288 949706423059171840 67605467670 20328 127121392200 320525917782470496 4979922756984 11088 4193619163776 624357777347103987 2095576889600 397488 1747341318240 6009860958421...

output:

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
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
12
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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
1
1
1
1...

result:

ok 66666 numbers

Test #32:

score: 0
Accepted
time: 240ms
memory: 20584kb

input:

100000 66666
938675916495 816153957316475800 2062833500700 302328 1682624973120 183634640396207055 1735207003530 59136 7544076802560 434045513663762130 304897897683346052 68640 3559398981600 641051835564940992 2542427844000 1100 190682088300 213683945188313664 15809278593600 9504 199696150656 467433...

output:

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

result:

ok 66666 numbers

Test #33:

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

input:

100000 66666
3182657401080 457046216097226448 46803785310 113807937197721993 1464785132850 701150445149154210 409870185760 4356 86288460160 340558787643874902 27735576480 1440 6712009508160 133552465742696040 612911973097553748 21658 32049999488 930415511340782412 1941028093992 96900 4271278777920 1...

output:

110612220752176565
693389412
2
26
2
45
1
4
210
3
4
1
16
12
1
696598974301538395
2
2
4
432156061661681961
4
583424347568553160
2
2
2
6
16
2
2
4
19260817
3
5
4
4160336472
4
1
2
2
353126150042911885
4
1
1
1
507620739797810562
2
510
2
4
4
607756552146080620
562477229833154225
8
318934077250808299
4
5777...

result:

ok 66666 numbers

Test #34:

score: 0
Accepted
time: 369ms
memory: 25376kb

input:

100000 66666
251997480 1777742222400 497762844593777280 444257781377760 319996800 43890 161998380 66665333340000 767976960230399232 26879462402688 623993760 86400 10751892480 1617247654561728 341323093435732992 959980800096 1763982360 86632 2822371776 115597688011560 133329333373333200 3384821191449...

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
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
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
2
1
1
1
1
1
2
2
1
1
1
...

result:

ok 66666 numbers

Test #35:

score: 0
Accepted
time: 362ms
memory: 25060kb

input:

100000 66666
16455835440 1343973120134400 296287407496296000 836249941416960 3225567744 20160 2495975040 106664533344000 293324533421333040 286714265628672 201597984 302400 3059969400 19199616001920 211549208952355344 2073558528207360 647993520 480 24076559232 561588768056160 136884782263288752 4607...

output:

1
1
1
1
1
1
2
1
1
1
1
2
1
1
1
6
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
1
1
1
1
2
1
2
1
2
1
1
4
1
2
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
1
1
1
1
1
4
1
1
3
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
2
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
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
4
2
1
...

result:

ok 66666 numbers

Test #36:

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

input:

100000 66666
5279947200 483545884492800 472874702364088416 388792224038880 13463865360 470016 1468785312 4159916800416 251844296371851600 70398592007040 17099829000 208080 6527934720 604432355616000 234659626737066432 195836083219584 25535744640 38016 30506361600 112317753611232 303990880091199696 5...

output:

1
3
6
2
2
16
1
2
2
2
2
6
4
2
9
2
2
1
2
2
2
2
3
753480753110112601
72
2
2
3
2
4
1
2
3
2
2
24
2
6
1
12
2
2
2
2
2
1
1
5333280
1
4
2
2
2
1
4
12
2
8
1
1
2
2
4
1
12
2
6
1
2
2
2
6
6
1
2
1
2
2
48
2
2
4
2
1
6
2
2
2
1
36
2
2
8
3
4
12
12
2
2
1
2
1
288
2
2
4
2
12
2
72
2
8
144
2
4
1
2
2
2
1
8
1
36
2
2
4
2
6
2
4
...

result:

ok 66666 numbers

Test #37:

score: 0
Accepted
time: 223ms
memory: 20724kb

input:

100000 66666
12767872320 71180798584896 410654346789866256 2572464105501696 7937920620 405000 3079969200 159996800016000 223993280067199776 1295974080129600 538336467770058785 16800 294663720 127109109040319086 194251755348473335 165074640480215327 27647723520 311168 50999490 403191936040320 9481197...

output:

108
637746924913004448
24
254432920168732434
12
4
3
144
4799952
24
1599984
12
24
4
4799952
24
7253188267392
36
36
6
18
64
6
4
2
57599424
8
12
1152
133330666680
9
24
1512
36
763728881041030964
4
3
4
12
48
2133312
6
6
395751684040370021
48
8
3
4
162
6
799992
144
36
32
230397696
120
4
17225693193770302...

result:

ok 66666 numbers

Test #38:

score: 0
Accepted
time: 190ms
memory: 16052kb

input:

100000 66666
73580591259630 996491788296388609 21993319585296 53040 50311515391200 996491788296388609 105654182321520 141570 197221140333504 996491788296388609 76814902963350 18816 1612164630095 996491788296388609 27311965498080 25344 9391482873024 996491788296388609 13416404104320 184800 3563732340...

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 66666 numbers

Test #39:

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

input:

100000 66666
80498424625920 996491788296388609 87326416000440 6528 36984953278650 996491788296388609 10589376096624 44352 30546277201800 996491788296388609 13584109155624 2400 8145673920480 996491788296388609 9702935111160 25920 27311965498080 996491788296388609 323431170372000 93600 65404970008560 ...

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 66666 numbers

Test #40:

score: 0
Accepted
time: 156ms
memory: 16132kb

input:

100000 66666
37949257323648 996491788296388609 190608769739232 290700 383325831552 996491788296388609 33960272889060 1280 79659899369400 996491788296388609 2587449362976 8736 112661857679580 996491788296388609 46717835720400 336600 43528445012565 996491788296388609 355774287409200 82944 503115153912...

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
998244353
1
1
1
1
117298098427712176
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
127775277184
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
10
1
1
1
1
1
1
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 66666 numbers

Test #41:

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

input:

100000 66666
263919835023552 996491788296388609 43603313339040 16380 28110560980480 996491788296388609 210829207353600 23040 5576192955858 996491788296388609 2036418480120 64800 402492123129600 996491788296388609 4438194393438 276480 23670370098336 996491788296388609 471710957932644491 26400 1149977...

output:

1
1
998244353
1
1
1
998244353
1
998244353
1
998244353
1
4
998244353
2
1
1
10
1
1
1
1
1
4
1
998244353
1
1
1
1
1
1
1
8
90463323055818757
1
574880278545664076
4
15
1
1
1
12
1
1
1
1
941249530677884727
1
1
1
1
1
1
1
998244353
1
996491788296388609
1
1
720
8
1
1
1
1
1
1
1
1
996491788296388609
1
1
1
34
1
1
...

result:

ok 66666 numbers

Test #42:

score: 0
Accepted
time: 916ms
memory: 39940kb

input:

100000 66666
573440000000000000 615726511554560000 939524096000000000 501760000000000000 234881024000000000 822083584000000000 841813590016000000 822083584000000000 587202560000000000 439040000000000000 420906795008000000 469762048000000000 939524096000000000 939524096000000000 538760697610240000 20...

output:

11468800
5734400
5734400
2867200
2867200
5734400
11468800
91750400
5734400
22937600
5734400
22937600
114688000
22937600
2867200
22937600
3670016000
5734400
2867200
11468800
2867200
2867200
11468800
458752000
1146880
2867200
5734400
11468800
11468800
11468800
11468800
2867200
22937600
11468800
573440...

result:

ok 66666 numbers

Test #43:

score: -100
Time Limit Exceeded

input:

100000 66666
639106080130990080 832169375170560000 863964909158400000 426070720087326720 758314343124172800 718994340147363840 852141440174653440 902961561600000000 780158789222400000 975198486528000000 520105859481600000 702142910300160000 552313896409497600 346737239654400000 585119091916800000 86...

output:

15482880
2580480
10321920
7741440
2580480
2580480
1290240
3870720
2580480
1290240
7741440
61931520
3870720
10321920
3870720
15482880
30965760
92897280
15482880
7741440
2580480
7741440
2580480
7741440
2580480
3870720
2580480
2580480
2580480
2580480
7741440
3870720
3870720
371589120
3870720
1290240
25...

result: