QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#754768#9543. Good PartitionspoetryfactoryWA 297ms20592kbC++2012.7kb2024-11-16 15:45:422024-11-16 15:45:46

Judging History

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

  • [2024-11-16 15:45:46]
  • 评测
  • 测评结果:WA
  • 用时:297ms
  • 内存:20592kb
  • [2024-11-16 15:45:42]
  • 提交

answer

// #pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define INF 0x3fffffff
#define overload3(a, b, c, d, ...) d
#define overload4(a, b, c, d, e, ...) e
#define all1(x) (x).begin(), (x).end()
#define all2(x, i) (x).begin() + (i), (x).end()
#define all3(x, i, j) (x).begin() + (i), (x).begin() + (j)
#define all(...) overload3(__VA_ARGS__, all3, all2, all1)(__VA_ARGS__)
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define eb emplace_back
#define mkp make_pair
#define lowbit(x) (x & -x)
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define REP1(a) for (ll _ = 1; _ <= a; ++_)
#define REP2(i, a) for (ll i = 1; i <= ll(a); ++i)
#define REP3(i, a, b) for (ll i = (a); i <= ll(b); ++i)
#define REP4(i, a, b, c) for (ll i = (a); i <= ll(b); i += (c))
#define PER(i, a, b) for (ll i = (a); i >= ll(b); --i)
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define REP(...) overload4(__VA_ARGS__, REP4, REP3, REP2, REP1)(__VA_ARGS__)
#define MT       \
    int tt;      \
    cin >> tt;   \
    while (tt--) \
    {            \
        solve(); \
    }
#define suffZero(x) (__builtin_ctz(x))
#define suffZeroll(x) (__builtin_ctzll(x))
#define preZero(x) (__builtin_clz(x))
#define preZeroll(x) (__builtin_clzll(x))
#define countOne(x) (__builtin_popcount(x))
#define countOnell(x) (__builtin_popcountll(x))
#define lastOne(x) (__builtin_ffs(x))
#define firstOne(x) (32 - preZero(x))
#define firstOnell(x) (64 - preZeroll(x))
#ifdef LOCAL
#include "dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
using namespace std;
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<int>> vvi;
mt19937_64 rng{chrono::steady_clock::now().time_since_epoch().count()};
#define endl '\n'
vvi dir = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {-1, 1}, {1, -1}, {-1, -1}};

int fac[int(2e5 + 10)];

class segtree // 只需要写 apply、pushdown、merge
{
public:
    int ls(int x) { return x << 1; }
    int rs(int x) { return x << 1 | 1; }
    struct node
    {
        // don't forget to set default value (used for leaves)
        // not necessarily neutral element!
        ll gcd = 0, add = 0;
        void apply(int l, int r, ll v)
        {
            gcd += v, add += v;
        }
    };
    int n;
    vector<node> tree;

    node merge(const node &a, const node &b) const
    {
        node res;
        res.gcd = gcd(a.gcd, b.gcd);
        return res;
    }

    inline void pushdown(int x, int l, int r)
    {
        int m = (l + r) >> 1;
        // pushdown from x into ls(x) and rs(x)
        if (tree[x].add != 0)
        {
            tree[ls(x)].apply(l, m, tree[x].add);
            tree[rs(x)].apply(m + 1, r, tree[x].add);
            tree[x].add = 0;
        }
    }

    inline void pushup(int x)
    {
        tree[x] = merge(tree[ls(x)], tree[rs(x)]);
    }

    void build(int x, int l, int r)
    {
        if (l == r)
        {
            return;
        }
        int m = (l + r) >> 1;
        build(ls(x), l, m), build(rs(x), m + 1, r);
        pushup(x);
    }

    template <typename M>
    void build(int x, int l, int r, const vector<M> &v)
    {
        if (l == r)
        {
            tree[x].apply(l, r, v[l]);
            return;
        }
        int m = (l + r) >> 1;
        build(ls(x), l, m, v), build(rs(x), m + 1, r, v);
        pushup(x);
    }

    node query(int x, int l, int r, int L, int R)
    {
        if (L <= l && r <= R)
        {
            return tree[x];
        }
        int m = (l + r) >> 1;
        pushdown(x, l, r);
        node res{};
        if (R <= m)
            res = query(ls(x), l, m, L, R);
        else if (L > m)
            res = query(rs(x), m + 1, r, L, R);
        else
            res = merge(query(ls(x), l, m, L, R), query(rs(x), m + 1, r, L, R));
        pushup(x);
        return res;
    }

    template <typename... M>
    void modify(int x, int l, int r, int L, int R, const M &...v)
    {
        if (L <= l && r <= R)
        {
            tree[x].apply(l, r, v...);
            return;
        }
        int m = (l + r) >> 1;
        pushdown(x, l, r);
        if (L <= m)
            modify(ls(x), l, m, L, R, v...);
        if (R > m)
            modify(rs(x), m + 1, r, L, R, v...);
        pushup(x);
    }

    void modify(int x, int l, int r, int p, const node v)
    {
        if (l == r)
        {
            tree[x] = v;
            return;
        }
        int m = (l + r) >> 1;
        pushdown(x, l, r);
        if (p <= m)
            modify(ls(x), l, m, p, v);
        if (p > m)
            modify(rs(x), m + 1, r, p, v);
        pushup(x);
    }

    int find_first_knowingly(int x, int l, int r, const function<bool(const node &)> &f)
    {
        if (l == r)
        {
            // return f(tree[x]) ? l : 0;
            return l;
        }
        pushdown(x, l, r);
        int m = (l + r) >> 1;
        int res;
        if (f(tree[ls(x)]))
            res = find_first_knowingly(ls(x), l, m, f);
        else
            res = find_first_knowingly(rs(x), m + 1, r, f);
        pushup(x);
        return res;
    }

    int find_first(int x, int l, int r, int L, int R, const function<bool(const node &)> &f)
    {
        if (L <= l && r <= R)
        {
            if (!f(tree[x]))
                return 0;
            return find_first_knowingly(x, l, r, f);
        }
        pushdown(x, l, r);
        int m = (l + r) >> 1;
        int res = 0;
        if (L <= m)
            res = find_first(ls(x), l, m, L, R, f);
        if (R > m && res == 0)
            res = find_first(rs(x), m + 1, r, L, R, f);
        pushup(x);
        return res;
    }

    int find_last_knowingly(int x, int l, int r, const function<bool(const node &)> &f)
    {
        if (l == r)
        {
            // return f(tree[x]) ? l : 0;
            return l;
        }
        pushdown(x, l, r);
        int m = (l + r) >> 1;
        int res;
        if (f(tree[rs(x)]))
            res = find_last_knowingly(rs(x), m + 1, r, f);
        else
            res = find_last_knowingly(ls(x), l, m, f);
        pushup(x);
        return res;
    }

    int find_last(int x, int l, int r, int L, int R, const function<bool(const node &)> &f)
    {
        if (L <= l && r <= R)
        {
            if (!f(tree[x]))
                return 0;
            return find_last_knowingly(x, l, r, f);
        }
        pushdown(x, l, r);
        int m = (l + r) >> 1;
        int res = 0;
        if (R > m)
            res = find_last(rs(x), m + 1, r, L, R, f);
        if (L <= m && res == 0)
            res = find_last(ls(x), l, m, L, R, f);
        pushup(x);
        return res;
    }

    segtree(int _n) : n(_n)
    {
        assert(n > 0);
        tree.resize(n << 2);
        build(1, 1, n);
    }

    template <typename M>
    segtree(const vector<M> &v)
    {
        n = v.size() - 1;
        assert(n > 0);
        tree.resize(n << 2);
        build(1, 1, n, v);
    }

    node query(int L, int R)
    {
        assert(1 <= L && L <= R && R <= n);
        return query(1, 1, n, L, R);
    }

    node query(int p)
    {
        assert(1 <= p && p <= n);
        return query(1, 1, n, p, p);
    }

    template <typename... M>
    void modify(int L, int R, const M &...v)
    {
        assert(1 <= L && L <= R && R <= n);
        modify(1, 1, n, L, R, v...);
    }

    void modify(int x, const node v)
    {
        assert(1 <= x && x <= n);
        modify(1, 1, n, x, v);
    }

    // find_first 和 find_last 只会在false的元素搜索最多一次
    // 只能用来求解大区间满足则小区间满足的性质,如最值

    int find_first(int L, int R, const function<bool(const node &)> &f)
    {
        assert(1 <= L && L <= R && R <= n);
        return find_first(1, 1, n, L, R, f);
    }

    int find_last(int L, int R, const function<bool(const node &)> &f)
    {
        assert(1 <= L && L <= R && R <= n);
        return find_last(1, 1, n, L, R, f);
    }
};

ostream &operator<<(ostream &out, const segtree::node &a) // 重载ostream可以通过debug输出tree数组的内容
{
    out << " [gcd=" << a.gcd << " add=" << a.add << "] ";
    return out;
}

ll mul(ll a, ll b, ll m)
{
    return static_cast<__int128>(a) * b % m;
}
ll power(ll a, ll b, ll m)
{
    ll res = 1 % m;
    for (; b; b >>= 1, a = mul(a, a, m))
        if (b & 1)
            res = mul(res, a, m);
    return res;
}
bool isprime(ll n)
{
    if (n < 2)
        return false;
    static constexpr int A[] = {2, 3, 5, 7, 11, 13, 17, 19, 23};
    int s = __builtin_ctzll(n - 1);
    ll d = (n - 1) >> s;
    for (auto a : A)
    {
        if (a == n)
            return true;
        ll x = power(a, d, n);
        if (x == 1 || x == n - 1)
            continue;
        bool ok = false;
        for (int i = 0; i < s - 1; ++i)
        {
            x = mul(x, x, n);
            if (x == n - 1)
            {
                ok = true;
                break;
            }
        }
        if (!ok)
            return false;
    }
    return true;
}
int factorize(ll n)
{
    assert(n >= 1);
    vector<ll> p;
    function<void(ll)> f = [&](ll n)
    {
        if (n <= 10000)
        {
            for (int i = 2; i * i <= n; ++i)
                for (; n % i == 0; n /= i)
                    p.push_back(i);
            if (n > 1)
                p.push_back(n);
            return;
        }
        if (isprime(n))
        {
            p.push_back(n);
            return;
        }
        auto g = [&](ll x)
        {
            return (mul(x, x, n) + 1) % n;
        };
        ll x0 = 2;
        while (true)
        {
            ll x = x0;
            ll y = x0;
            ll d = 1;
            ll power = 1, lam = 0;
            ll v = 1;
            while (d == 1)
            {
                y = g(y);
                ++lam;
                v = mul(v, abs(x - y), n);
                if (lam % 127 == 0)
                {
                    d = gcd(v, n);
                    v = 1;
                }
                if (power == lam)
                {
                    x = y;
                    power *= 2;
                    lam = 0;
                    d = gcd(v, n);
                    v = 1;
                }
            }
            if (d != n)
            {
                f(d);
                f(n / d);
                return;
            }
            ++x0;
        }
    };
    f(n);
    sort(p.begin(), p.end());
    if (p.empty())
        return 0;
    ll cur = p[0];
    int pos = 0;
    int res = 1;
    while (pos < sz(p))
    {
        int q = 0;
        while (p[pos] == cur)
        {
            q++;
            pos++;
        }
        res *= q + 1;
        cur = p[pos];
        q = 0;
    }
    return res;
}

void solve()
{
    int n, q;
    cin >> n >> q;
    vi a(n + 1);
    REP(i, 1, n)
    {
        cin >> a[i];
    }
    vi g(n + 1);
    REP(i, 1, n - 1)
    {
        if (a[i] > a[i + 1])
            g[i] = i;
    }
    segtree s(g);
    int res = s.tree[1].gcd;
    cout << (res != 0 ? fac[res] : n) << endl;
    REP(i, 1, q)
    {
        int p, x;
        cin >> p >> x;
        a[p] = x;
        if (p < n)
        {
            if (a[p] > a[p + 1])
                s.modify(p, {p, 0});
            else
            {
                s.modify(p, {0, 0});
            }
        }
        if (p > 1)
        {
            if (a[p - 1] > a[p])
                s.modify(p - 1, {p - 1, 0});
            else
            {
                s.modify(p - 1, {0, 0});
            }
        }
        int res = s.tree[1].gcd;
        cout << (res != 0 ? fac[res] : n) << endl;
    }
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    clock_t st = clock();
#ifdef LOCAL
    freopen("in.in", "r", stdin);
    freopen("out.out", "w", stdout);
#endif
    //-------------------------------------
    fac[1] = 1;
    int mx = 0;
    int ind = 0;
    REP(i, 2, 2e5)
    {
        fac[i] = factorize(i);
    }
    MT;
//-------------------------------------
#ifdef LOCAL
    cerr << "Time:" << clock() - st << "ms\n";
#endif
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 180ms
memory: 5428kb

input:

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

output:

1
2
3

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 181ms
memory: 5240kb

input:

1
1 1
2000000000
1 1999999999

output:

1
1

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 255ms
memory: 20480kb

input:

1
200000 200000
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160
200000
160...

result:

ok 200001 lines

Test #4:

score: 0
Accepted
time: 261ms
memory: 20592kb

input:

1
200000 200000
200001 200000 199999 199998 199997 199996 199995 199994 199993 199992 199991 199990 199989 199988 199987 199986 199985 199984 199983 199982 199981 199980 199979 199978 199977 199976 199975 199974 199973 199972 199971 199970 199969 199968 199967 199966 199965 199964 199963 199962 1999...

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

Test #5:

score: 0
Accepted
time: 247ms
memory: 20520kb

input:

1
200000 200000
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200001 lines

Test #6:

score: 0
Accepted
time: 177ms
memory: 5428kb

input:

2
2 2
17017 63462
2 94054
2 13504
8 8
14380 5840 34752 73602 60279 26105 44308 78318
7 8597
2 70671
6 56663
5 90093
5 96853
3 10700
1 76875
6 27325

output:

2
2
1
1
1
1
1
1
1
1
1
1

result:

ok 12 lines

Test #7:

score: 0
Accepted
time: 177ms
memory: 5216kb

input:

10
9 15
850456 510799 912572 938543 215712 758501 850577 149454 330027
7 740992
7 73826
1 993823
7 143019
8 152824
2 109975
5 151989
7 851016
3 157534
8 491512
6 987473
7 272348
3 842756
4 278214
5 707564
10 17
494099 922564 124251 422938 100551 915266 18436 74858 885629 897256
8 798574
7 49544
7 83...

output:

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

result:

ok 110 lines

Test #8:

score: 0
Accepted
time: 178ms
memory: 5300kb

input:

10
133 246
140510 608816 589575 476955 565233 554161 572604 339315 619706 665193 478181 434356 152086 642681 20634 515330 792629 985669 964199 254936 124166 33376 866759 559350 243009 210630 84226 54133 562576 188482 341088 287802 931163 132016 885704 128841 718254 917725 716410 175025 922633 18826 ...

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

Test #9:

score: 0
Accepted
time: 185ms
memory: 5508kb

input:

10
3872 687
44064166 27154700 47734073 23232952 85900163 60570475 79562375 95316865 5283870 83145253 18727311 84521331 87003172 67383345 87258243 56070949 93690923 24354578 82428308 54239011 31728698 60725336 28686234 19515381 86019850 20774145 91634419 99792041 34779827 43899611 5776212 38860142 22...

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

Test #10:

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

input:

10
16568 3726
108245963 1072826507 922424573 1724795997 821224456 920893777 1197351187 1750418758 475004108 473502990 1018456990 1361563534 750892494 1656602758 1227777726 25842374 1616734168 755178190 1192059348 549671897 71441917 604937525 380135847 1750880898 478060006 1256638169 469752575 429941...

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

Test #11:

score: 0
Accepted
time: 269ms
memory: 8752kb

input:

10
49420 24551
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 1...

output:

49420
10
4
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

result:

ok 200010 lines

Test #12:

score: 0
Accepted
time: 282ms
memory: 10492kb

input:

10
10300 2652
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

10300
8
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 200010 lines

Test #13:

score: 0
Accepted
time: 268ms
memory: 11440kb

input:

10
28101 16542
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 1...

output:

28101
24
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6...

result:

ok 200010 lines

Test #14:

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

input:

1
200000 200000
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

200000
12
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
...

result:

ok 200001 lines

Test #15:

score: 0
Accepted
time: 261ms
memory: 20588kb

input:

1
200000 200000
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

200000
8
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4...

result:

ok 200001 lines

Test #16:

score: 0
Accepted
time: 264ms
memory: 20564kb

input:

1
200000 200000
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

200000
16
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
8
...

result:

ok 200001 lines

Test #17:

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

input:

1
200000 200000
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

output:

200000
56
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12...

result:

ok 200001 lines

Test #18:

score: -100
Wrong Answer
time: 281ms
memory: 10312kb

input:

10
26336 1286
228421897 1791532791 425024350 1053512919 787210054 151846650 1744204584 405715098 1511878042 83024903 1407242089 1343378225 1247367760 621669758 747664439 1732435705 9687958 844692771 1240968969 764906143 1044324581 1922020674 1464231730 664066323 1878006024 1467739885 1274788859 9888...

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:

wrong answer 31694th lines differ - expected: '90', found: '180'