QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499978#6551. Forever YoungpandapythonerAC ✓668ms68980kbC++234.6kb2024-07-31 20:43:522024-07-31 20:43:54

Judging History

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

  • [2024-07-31 20:43:54]
  • 评测
  • 测评结果:AC
  • 用时:668ms
  • 内存:68980kb
  • [2024-07-31 20:43:52]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;


#define ll long long
#define flt double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, n) for(int i = 0; i < n; i += 1)
#define len(a) ((int)(a).size())


const ll inf = 1e18;
mt19937 rnd(234);
const ll mod = 998244353;


ll bin_pow(ll x, ll n) {
    assert(0 <= x and x < mod and n >= 0);
    ll rs = 1;
    for (ll i = 1, a = x; i <= n; i *= 2, a = a * a % mod) {
        if (n & i) {
            rs = rs * a % mod;
        }
    }
    return rs;
}


ll inv(ll x) {
    assert(x != 0);
    ll a = bin_pow(x, mod - 2);
    assert(a * x % mod == 1);
    return a;
}



ll solve(vector<int> a, vector<int> b, ll k) {
    int n = len(a), m = len(b);
    auto get_dp = [&](vector<int> a) -> map<vector<int>, ll> {
        map<vector<int>, ll> dp;
        dp[a] = 1;
        queue<vector<int>> q;
        q.push(a);
        while (!q.empty()) {
            auto v = q.front();
            q.pop();
            ll val = dp[v];
            rep(i, len(v)) {
                assert(v[i] > 0);
                if (i + 1 < len(v) and v[i] == v[i + 1]) continue;
                auto to = v;
                to[i] -= 1;
                if (to.back() == 0) {
                    to.pop_back();
                }
                auto it = dp.find(to);
                if (it == dp.end()) {
                    dp[to] = dp[v];
                    q.push(to);
                } else {
                    it->second = (it->second + val);
                    if (it->second >= mod) {
                        it->second -= mod;
                    }
                }
            }
        }
        return dp;
        };
    auto dpa = get_dp(a);
    auto dpb = get_dp(b);
    ll fsize = 2 * k + 1000;
    vector<ll> f(fsize + 1), invf(fsize + 1);
    f[0] = invf[0] = 1;
    for (int i = 1; i <= fsize; i += 1) {
        f[i] = (f[i - 1] * i) % mod;
        invf[i] = inv(f[i]);
    }
    ll sma = 0, smb = 0;
    rep(i, n) sma += a[i];
    rep(i, m) smb += b[i];
    ll inv2 = inv(2);
    ll result = 0;
    for (auto [v, vala] : dpa) {
        auto it = dpb.find(v);
        if (it == dpb.end()) continue;
        ll valb = it->second;
        ll msum = 0;
        rep(i, len(v)) msum += v[i];
        assert(msum <= sma and msum <= smb);
        ll down = sma - msum;
        ll up = smb - msum;
        if (down + up > k or (down + up) % 2 != k % 2) continue;
        ll coeff = f[down + up] * invf[down] % mod * invf[up] % mod;
        // for (ll x = down + up; x < k; x += 2) coeff = coeff * (x + 1) % mod * (x + 2) % mod * inv2 % mod;
        coeff = coeff * f[k] % mod * invf[up + down] % mod;
        coeff = coeff * inv(bin_pow(2, (k - down - up) / 2)) % mod;
        coeff = coeff * invf[(k - down - up) / 2] % mod;
        result = (result + coeff * vala % mod * valb) % mod;
    }
    return result;
}



ll solve_slow(vector<int> a, vector<int> b, ll k) {
    vector<map<vector<int>, ll>> dp(k + 1);
    dp[0][a] = 1;
    for (ll i = 0; i < k; i += 1) {
        for (auto [v, val] : dp[i]) {
            for (int j = 0; j < len(v); j += 1) {
                for (auto d : { -1, 1 }) {
                    auto to = v;
                    to[j] += d;
                    if (j > 0 and to[j - 1] < to[j]) continue;
                    if (j + 1 < len(to) and to[j] < to[j + 1]) continue;
                    if (to.back() == 0) {
                        to.pop_back();
                    }
                    dp[i + 1][to] = (dp[i + 1][to] + dp[i][v]) % mod;
                }
            }
            auto to = v;
            to.push_back(1);
            dp[i + 1][to] = (dp[i + 1][to] + dp[i][v]) % mod;
        }
    }
    return dp[k][b];
}


void stress() {
    ll c = 0;
    while (1) {
        cout << ++c << "\n";
        vector<int> a, b;
        for (int x = rnd() % 5 + 1; x > 0; x = rnd() % (x + 1)) a.push_back(x);
        for (int x = rnd() % 5 + 1; x > 0; x = rnd() % (x + 1)) b.push_back(x);
        int k = rnd() % 10 + 1;
        ll right_res = solve_slow(a, b, k);
        ll my_res = solve(a, b, k);
        if (right_res != my_res) {
            break;
        }
    }
}

int32_t main() {
    // stress();
    if (1) {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    int n; cin >> n;
    vector<int> a(n); rep(i, n) cin >> a[i];
    int m; cin >> m;
    vector<int> b(m); rep(i, m) cin >> b[i];
    ll k;
    cin >> k;
    ll result = solve(a, b, k);
    cout << result << "\n";
    return 0;
}

/*
2
1 1
2
2 2
6


*/

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3572kb

input:

3
3 2 1
3
3 2 1
2

output:

7

result:

ok 1 number(s): "7"

Test #2:

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

input:

3
3 2 1
3
3 2 1
1111

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

0

0

10

output:

945

result:

ok 1 number(s): "945"

Test #4:

score: 0
Accepted
time: 493ms
memory: 53184kb

input:

10
10 9 8 7 6 5 4 4 4 3
10
10 9 8 7 6 5 4 4 4 3
1000000

output:

591072522

result:

ok 1 number(s): "591072522"

Test #5:

score: 0
Accepted
time: 361ms
memory: 44624kb

input:

10
10 9 8 7 6 5 4 4 4 3
6
10 10 10 10 10 10
1000000

output:

954562178

result:

ok 1 number(s): "954562178"

Test #6:

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

input:

1
59
1
60
999999

output:

621240518

result:

ok 1 number(s): "621240518"

Test #7:

score: 0
Accepted
time: 38ms
memory: 8768kb

input:

6
10 10 10 10 10 10
5
12 12 12 12 12
122220

output:

996858520

result:

ok 1 number(s): "996858520"

Test #8:

score: 0
Accepted
time: 250ms
memory: 35692kb

input:

5
5 4 3 2 1
5
20 10 10 10 10
999999

output:

395659998

result:

ok 1 number(s): "395659998"

Test #9:

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

input:

9
10 9 8 7 6 5 5 5 5
9
10 9 8 7 6 5 5 5 5
100000

output:

350064296

result:

ok 1 number(s): "350064296"

Test #10:

score: 0
Accepted
time: 281ms
memory: 38956kb

input:

6
13 11 8 7 6 5
7
11 11 9 8 7 6 5
1000000

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 354ms
memory: 44804kb

input:

7
13 12 9 8 7 6 5
7
13 12 9 8 7 6 5
1000000

output:

130449432

result:

ok 1 number(s): "130449432"

Test #12:

score: 0
Accepted
time: 348ms
memory: 44320kb

input:

7
13 12 9 8 7 6 5
7
13 11 9 8 7 6 5
999999

output:

449198110

result:

ok 1 number(s): "449198110"

Test #13:

score: 0
Accepted
time: 400ms
memory: 48112kb

input:

7
15 12 9 8 7 6 3
7
15 12 9 8 7 6 3
1000000

output:

553218647

result:

ok 1 number(s): "553218647"

Test #14:

score: 0
Accepted
time: 238ms
memory: 34364kb

input:

0

0

1000000

output:

765860359

result:

ok 1 number(s): "765860359"

Test #15:

score: 0
Accepted
time: 246ms
memory: 34380kb

input:

1
1
1
1
1000000

output:

71283935

result:

ok 1 number(s): "71283935"

Test #16:

score: 0
Accepted
time: 241ms
memory: 35080kb

input:

3
20 20 20
20
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
1000000

output:

708368272

result:

ok 1 number(s): "708368272"

Test #17:

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

input:

3
8 1 1
3
5 4 1
5

output:

0

result:

ok 1 number(s): "0"

Test #18:

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

input:

3
7 2 1
3
5 4 1
3

output:

0

result:

ok 1 number(s): "0"

Test #19:

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

input:

4
5 2 2 1
4
4 3 2 1
5

output:

0

result:

ok 1 number(s): "0"

Test #20:

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

input:

4
4 3 2 1
4
3 3 2 2
4

output:

60

result:

ok 1 number(s): "60"

Test #21:

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

input:

5
4 2 2 1 1
5
4 2 2 1 1
5

output:

0

result:

ok 1 number(s): "0"

Test #22:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #23:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #24:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #25:

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

input:

7
2 2 2 1 1 1 1
7
2 2 2 1 1 1 1
5

output:

0

result:

ok 1 number(s): "0"

Test #26:

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

input:

7
4 1 1 1 1 1 1
7
3 2 1 1 1 1 1
1

output:

0

result:

ok 1 number(s): "0"

Test #27:

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

input:

8
2 2 1 1 1 1 1 1
8
2 2 1 1 1 1 1 1
5

output:

0

result:

ok 1 number(s): "0"

Test #28:

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

input:

8
2 2 1 1 1 1 1 1
8
2 2 1 1 1 1 1 1
1

output:

0

result:

ok 1 number(s): "0"

Test #29:

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

input:

9
2 1 1 1 1 1 1 1 1
9
2 1 1 1 1 1 1 1 1
5

output:

0

result:

ok 1 number(s): "0"

Test #30:

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

input:

9
2 1 1 1 1 1 1 1 1
9
2 1 1 1 1 1 1 1 1
1

output:

0

result:

ok 1 number(s): "0"

Test #31:

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

input:

10
1 1 1 1 1 1 1 1 1 1
10
1 1 1 1 1 1 1 1 1 1
5

output:

0

result:

ok 1 number(s): "0"

Test #32:

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

input:

10
1 1 1 1 1 1 1 1 1 1
10
1 1 1 1 1 1 1 1 1 1
3

output:

0

result:

ok 1 number(s): "0"

Test #33:

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

input:

1
20
1
20
0

output:

1

result:

ok 1 number(s): "1"

Test #34:

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

input:

1
20
1
21
1

output:

1

result:

ok 1 number(s): "1"

Test #35:

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

input:

1
20
1
22
1

output:

0

result:

ok 1 number(s): "0"

Test #36:

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

input:

3
11 7 2
4
14 3 2 1
0

output:

0

result:

ok 1 number(s): "0"

Test #37:

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

input:

60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
60
1000000

output:

876113637

result:

ok 1 number(s): "876113637"

Test #38:

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

input:

1
60
60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

876113637

result:

ok 1 number(s): "876113637"

Test #39:

score: 0
Accepted
time: 198ms
memory: 29712kb

input:

60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1
60
853105

output:

0

result:

ok 1 number(s): "0"

Test #40:

score: 0
Accepted
time: 172ms
memory: 25960kb

input:

1
60
60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
727238

output:

177047655

result:

ok 1 number(s): "177047655"

Test #41:

score: 0
Accepted
time: 234ms
memory: 34552kb

input:

1
60
1
60
1000000

output:

921463967

result:

ok 1 number(s): "921463967"

Test #42:

score: 0
Accepted
time: 61ms
memory: 10840kb

input:

1
60
1
60
243870

output:

509116683

result:

ok 1 number(s): "509116683"

Test #43:

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

input:

2
50 10
2
55 5
1000000

output:

861843225

result:

ok 1 number(s): "861843225"

Test #44:

score: 0
Accepted
time: 22ms
memory: 6876kb

input:

2
45 15
2
51 9
111774

output:

12281419

result:

ok 1 number(s): "12281419"

Test #45:

score: 0
Accepted
time: 238ms
memory: 34912kb

input:

3
23 21 16
3
27 21 12
1000000

output:

652026360

result:

ok 1 number(s): "652026360"

Test #46:

score: 0
Accepted
time: 237ms
memory: 34416kb

input:

3
31 19 10
3
27 23 10
979678

output:

673323950

result:

ok 1 number(s): "673323950"

Test #47:

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

input:

4
22 22 9 7
4
28 16 10 6
1000000

output:

5948265

result:

ok 1 number(s): "5948265"

Test #48:

score: 0
Accepted
time: 220ms
memory: 32212kb

input:

4
28 12 11 9
4
28 25 5 2
880286

output:

21805708

result:

ok 1 number(s): "21805708"

Test #49:

score: 0
Accepted
time: 274ms
memory: 38880kb

input:

5
23 13 8 8 8
5
23 17 12 6 2
1000000

output:

587098080

result:

ok 1 number(s): "587098080"

Test #50:

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

input:

5
30 14 12 3 1
5
28 13 12 6 1
748190

output:

2626249

result:

ok 1 number(s): "2626249"

Test #51:

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

input:

6
22 11 9 8 5 5
6
19 18 11 9 2 1
1000000

output:

488941862

result:

ok 1 number(s): "488941862"

Test #52:

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

input:

6
18 13 13 8 4 4
6
20 13 9 8 6 4
648799

output:

0

result:

ok 1 number(s): "0"

Test #53:

score: 0
Accepted
time: 402ms
memory: 48092kb

input:

7
22 16 9 6 4 2 1
7
19 16 11 8 3 2 1
1000000

output:

493787537

result:

ok 1 number(s): "493787537"

Test #54:

score: 0
Accepted
time: 217ms
memory: 28772kb

input:

7
14 14 12 11 5 2 2
7
22 18 8 6 4 1 1
516703

output:

0

result:

ok 1 number(s): "0"

Test #55:

score: 0
Accepted
time: 506ms
memory: 56352kb

input:

8
20 12 7 7 4 4 3 3
8
18 13 8 6 6 5 2 2
1000000

output:

468062792

result:

ok 1 number(s): "468062792"

Test #56:

score: 0
Accepted
time: 272ms
memory: 32276kb

input:

8
18 14 9 7 6 4 1 1
8
24 13 10 7 2 2 1 1
384607

output:

0

result:

ok 1 number(s): "0"

Test #57:

score: 0
Accepted
time: 597ms
memory: 63684kb

input:

9
17 12 10 5 5 4 3 3 1
9
22 12 8 6 4 3 2 2 1
1000000

output:

829982699

result:

ok 1 number(s): "829982699"

Test #58:

score: 0
Accepted
time: 323ms
memory: 34856kb

input:

9
22 11 10 4 3 3 3 2 2
9
15 14 7 7 6 5 3 2 1
285215

output:

0

result:

ok 1 number(s): "0"

Test #59:

score: 0
Accepted
time: 582ms
memory: 64004kb

input:

10
20 10 7 5 4 3 3 3 3 2
10
17 10 8 8 6 4 4 1 1 1
1000000

output:

750051767

result:

ok 1 number(s): "750051767"

Test #60:

score: 0
Accepted
time: 402ms
memory: 39300kb

input:

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

output:

377561452

result:

ok 1 number(s): "377561452"

Test #61:

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

input:

11
10 9 8 6 6 5 4 4 4 3 1
11
20 6 6 6 5 5 5 3 2 1 1
1000000

output:

461938227

result:

ok 1 number(s): "461938227"

Test #62:

score: 0
Accepted
time: 650ms
memory: 63872kb

input:

11
12 10 8 6 5 5 4 4 2 2 2
11
15 11 9 8 6 4 2 2 1 1 1
752918

output:

470855619

result:

ok 1 number(s): "470855619"

Test #63:

score: 0
Accepted
time: 635ms
memory: 65804kb

input:

12
10 7 6 6 6 6 5 4 3 3 2 2
12
12 10 7 6 6 4 4 3 3 2 2 1
1000000

output:

923732206

result:

ok 1 number(s): "923732206"

Test #64:

score: 0
Accepted
time: 668ms
memory: 68980kb

input:

12
16 9 7 7 4 4 3 3 2 2 2 1
12
12 8 6 5 5 5 5 4 3 3 2 2
943649

output:

0

result:

ok 1 number(s): "0"

Test #65:

score: 0
Accepted
time: 637ms
memory: 65060kb

input:

13
12 10 9 7 5 4 2 2 2 2 2 2 1
13
9 8 6 6 5 5 5 5 4 2 2 2 1
1000000

output:

499284829

result:

ok 1 number(s): "499284829"

Test #66:

score: 0
Accepted
time: 558ms
memory: 52344kb

input:

13
14 10 9 7 4 4 2 2 2 2 2 1 1
13
17 10 5 4 4 4 3 3 3 2 2 2 1
325869

output:

0

result:

ok 1 number(s): "0"

Test #67:

score: 0
Accepted
time: 492ms
memory: 56016kb

input:

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

output:

939276767

result:

ok 1 number(s): "939276767"

Test #68:

score: 0
Accepted
time: 588ms
memory: 55904kb

input:

14
10 8 6 6 5 5 3 3 3 3 3 3 1 1
14
13 12 6 5 5 4 3 3 2 2 2 1 1 1
483896

output:

882469840

result:

ok 1 number(s): "882469840"

Test #69:

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

input:

15
10 6 6 6 5 4 4 3 3 3 2 2 2 2 2
15
8 6 6 6 5 5 4 4 3 3 2 2 2 2 2
1000000

output:

825426039

result:

ok 1 number(s): "825426039"

Test #70:

score: 0
Accepted
time: 648ms
memory: 68172kb

input:

15
9 8 7 7 6 5 5 3 2 2 2 1 1 1 1
15
15 11 9 4 4 3 3 3 2 1 1 1 1 1 1
866115

output:

0

result:

ok 1 number(s): "0"

Test #71:

score: 0
Accepted
time: 619ms
memory: 66912kb

input:

16
11 7 7 7 6 4 3 3 2 2 2 2 1 1 1 1
16
8 7 6 6 6 5 4 4 3 2 2 2 2 1 1 1
1000000

output:

924281746

result:

ok 1 number(s): "924281746"

Test #72:

score: 0
Accepted
time: 367ms
memory: 34724kb

input:

16
10 10 8 5 4 3 3 3 2 2 2 2 2 2 1 1
16
8 8 7 5 5 4 4 4 4 3 2 2 1 1 1 1
24143

output:

0

result:

ok 1 number(s): "0"

Test #73:

score: 0
Accepted
time: 633ms
memory: 66332kb

input:

17
9 7 6 5 5 4 4 4 3 2 2 2 2 2 1 1 1
17
10 9 5 5 4 3 3 3 3 3 3 2 2 2 1 1 1
1000000

output:

780050380

result:

ok 1 number(s): "780050380"

Test #74:

score: 0
Accepted
time: 524ms
memory: 51988kb

input:

17
8 7 5 5 5 5 3 3 3 3 3 2 2 2 2 1 1
17
11 8 6 5 5 4 4 3 3 2 2 2 1 1 1 1 1
439066

output:

184653936

result:

ok 1 number(s): "184653936"

Test #75:

score: 0
Accepted
time: 512ms
memory: 58204kb

input:

18
16 8 5 3 3 3 3 3 2 2 2 2 2 2 1 1 1 1
18
9 5 5 5 5 5 4 4 3 3 2 2 2 2 1 1 1 1
1000000

output:

521674675

result:

ok 1 number(s): "521674675"

Test #76:

score: 0
Accepted
time: 331ms
memory: 36888kb

input:

18
8 6 5 5 5 4 3 3 3 3 3 3 2 2 2 1 1 1
18
6 5 5 5 4 4 4 4 4 3 3 3 2 2 2 2 1 1
597094

output:

767080267

result:

ok 1 number(s): "767080267"

Test #77:

score: 0
Accepted
time: 459ms
memory: 53932kb

input:

19
10 7 6 5 3 3 3 3 3 2 2 2 2 2 2 2 1 1 1
19
6 5 5 4 4 4 4 4 3 3 3 2 2 2 2 2 2 2 1
1000000

output:

852853752

result:

ok 1 number(s): "852853752"

Test #78:

score: 0
Accepted
time: 404ms
memory: 37368kb

input:

19
9 9 6 5 5 4 3 3 2 2 2 2 2 1 1 1 1 1 1
19
11 6 6 5 4 3 3 3 2 2 2 2 2 2 2 2 1 1 1
12017

output:

0

result:

ok 1 number(s): "0"

Test #79:

score: 0
Accepted
time: 459ms
memory: 53592kb

input:

20
7 6 5 4 4 4 4 3 3 3 3 2 2 2 2 2 1 1 1 1
20
10 5 5 4 4 4 3 3 3 3 3 2 2 2 2 1 1 1 1 1
1000000

output:

733048530

result:

ok 1 number(s): "733048530"

Test #80:

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

input:

20
7 7 5 5 5 4 4 4 3 2 2 2 2 2 1 1 1 1 1 1
20
7 7 4 4 4 3 3 3 3 3 3 3 2 2 2 2 2 1 1 1
202676

output:

156353593

result:

ok 1 number(s): "156353593"

Test #81:

score: 0
Accepted
time: 402ms
memory: 49684kb

input:

21
7 7 5 5 5 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 1
21
6 5 5 5 4 4 3 3 3 3 3 2 2 2 2 2 2 1 1 1 1
1000000

output:

757271795

result:

ok 1 number(s): "757271795"

Test #82:

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

input:

21
6 6 5 5 4 4 4 4 3 3 2 2 2 2 2 1 1 1 1 1 1
21
7 7 7 5 4 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1
328000

output:

990016928

result:

ok 1 number(s): "990016928"

Test #83:

score: 0
Accepted
time: 353ms
memory: 45524kb

input:

22
5 5 4 4 4 4 3 3 3 3 3 3 2 2 2 2 2 2 1 1 1 1
22
7 5 5 4 4 4 4 3 3 3 3 2 2 2 2 1 1 1 1 1 1 1
1000000

output:

16197312

result:

ok 1 number(s): "16197312"

Test #84:

score: 0
Accepted
time: 384ms
memory: 45000kb

input:

22
6 6 5 5 4 4 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1
22
8 8 6 4 4 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1
742923

output:

0

result:

ok 1 number(s): "0"

Test #85:

score: 0
Accepted
time: 407ms
memory: 49148kb

input:

23
6 5 4 4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 1 1 1
23
7 6 5 5 4 4 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1 1 1
1000000

output:

614567909

result:

ok 1 number(s): "614567909"

Test #86:

score: 0
Accepted
time: 469ms
memory: 54772kb

input:

23
9 5 5 4 4 4 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1 1 1
23
10 6 5 4 4 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1
900951

output:

0

result:

ok 1 number(s): "0"

Test #87:

score: 0
Accepted
time: 397ms
memory: 48932kb

input:

24
7 5 5 4 3 3 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 1 1 1
24
9 5 4 4 3 3 3 3 3 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1
1000000

output:

774201895

result:

ok 1 number(s): "774201895"

Test #88:

score: 0
Accepted
time: 158ms
memory: 21600kb

input:

24
6 5 5 4 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1
24
5 5 5 4 4 4 3 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1
315874

output:

225844225

result:

ok 1 number(s): "225844225"

Test #89:

score: 0
Accepted
time: 343ms
memory: 44872kb

input:

25
7 5 5 4 4 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1
25
5 4 4 4 4 3 3 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 1 1 1
1000000

output:

772128610

result:

ok 1 number(s): "772128610"

Test #90:

score: 0
Accepted
time: 299ms
memory: 34824kb

input:

25
7 6 5 4 4 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1
25
7 7 5 4 4 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1
473902

output:

802359366

result:

ok 1 number(s): "802359366"

Test #91:

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

input:

26
5 5 4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1
26
6 6 5 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1
1000000

output:

962591477

result:

ok 1 number(s): "962591477"

Test #92:

score: 0
Accepted
time: 277ms
memory: 36820kb

input:

26
6 5 4 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1
26
6 4 4 4 4 3 3 3 3 3 3 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
823417

output:

0

result:

ok 1 number(s): "0"

Test #93:

score: 0
Accepted
time: 336ms
memory: 43612kb

input:

27
5 4 3 3 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1
27
8 5 5 4 4 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

575905204

result:

ok 1 number(s): "575905204"

Test #94:

score: 0
Accepted
time: 85ms
memory: 11044kb

input:

27
6 4 4 4 3 3 3 3 3 3 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
27
6 4 4 4 3 3 3 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1
14148

output:

676701037

result:

ok 1 number(s): "676701037"

Test #95:

score: 0
Accepted
time: 281ms
memory: 38328kb

input:

28
4 4 4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1
28
5 4 4 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1
1000000

output:

275525428

result:

ok 1 number(s): "275525428"

Test #96:

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

input:

28
6 6 5 4 4 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1
28
4 4 4 4 3 3 3 3 3 3 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
396368

output:

460189772

result:

ok 1 number(s): "460189772"

Test #97:

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

input:

29
4 4 4 4 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1
29
4 4 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1
1000000

output:

26704187

result:

ok 1 number(s): "26704187"

Test #98:

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

input:

29
5 5 4 3 3 3 3 3 3 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1
29
5 5 4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1
587099

output:

0

result:

ok 1 number(s): "0"

Test #99:

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

input:

30
5 4 4 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1
30
5 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1
1000000

output:

743366177

result:

ok 1 number(s): "743366177"

Test #100:

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

input:

30
5 5 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
30
4 4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
777759

output:

0

result:

ok 1 number(s): "0"

Test #101:

score: 0
Accepted
time: 274ms
memory: 37772kb

input:

31
4 4 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1
31
6 5 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

85790599

result:

ok 1 number(s): "85790599"

Test #102:

score: 0
Accepted
time: 253ms
memory: 35140kb

input:

31
4 4 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1
31
4 4 4 4 3 3 3 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1
935786

output:

144534325

result:

ok 1 number(s): "144534325"

Test #103:

score: 0
Accepted
time: 272ms
memory: 39116kb

input:

32
9 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
32
5 4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

302041711

result:

ok 1 number(s): "302041711"

Test #104:

score: 0
Accepted
time: 106ms
memory: 16316kb

input:

32
4 3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1
32
5 4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
318005

output:

0

result:

ok 1 number(s): "0"

Test #105:

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

input:

33
5 4 4 3 3 3 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
33
4 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

626698831

result:

ok 1 number(s): "626698831"

Test #106:

score: 0
Accepted
time: 189ms
memory: 27192kb

input:

33
4 4 4 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1
33
4 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1
700225

output:

0

result:

ok 1 number(s): "0"

Test #107:

score: 0
Accepted
time: 271ms
memory: 37480kb

input:

34
5 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
34
4 4 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

686358144

result:

ok 1 number(s): "686358144"

Test #108:

score: 0
Accepted
time: 220ms
memory: 31276kb

input:

34
3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1
34
6 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1
858252

output:

262836004

result:

ok 1 number(s): "262836004"

Test #109:

score: 0
Accepted
time: 262ms
memory: 36816kb

input:

35
4 4 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
35
4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

743797074

result:

ok 1 number(s): "743797074"

Test #110:

score: 0
Accepted
time: 90ms
memory: 14044kb

input:

35
4 4 4 3 3 3 3 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
35
4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
273176

output:

881213265

result:

ok 1 number(s): "881213265"

Test #111:

score: 0
Accepted
time: 258ms
memory: 36396kb

input:

36
4 4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
36
4 4 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

258246646

result:

ok 1 number(s): "258246646"

Test #112:

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

input:

36
3 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
36
4 3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
431203

output:

0

result:

ok 1 number(s): "0"

Test #113:

score: 0
Accepted
time: 251ms
memory: 35500kb

input:

37
3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
37
4 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

237398946

result:

ok 1 number(s): "237398946"

Test #114:

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

input:

37
3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
37
3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
813423

output:

0

result:

ok 1 number(s): "0"

Test #115:

score: 0
Accepted
time: 249ms
memory: 35704kb

input:

38
4 4 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
38
3 3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

702787308

result:

ok 1 number(s): "702787308"

Test #116:

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

input:

38
3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
38
5 4 3 3 3 2 2 2 2 2 2 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
971450

output:

101557094

result:

ok 1 number(s): "101557094"

Test #117:

score: 0
Accepted
time: 244ms
memory: 35240kb

input:

39
3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
39
3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

708574105

result:

ok 1 number(s): "708574105"

Test #118:

score: 0
Accepted
time: 95ms
memory: 14968kb

input:

39
3 3 3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
39
3 3 3 3 2 2 2 2 2 2 2 2 2 2 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
353669

output:

0

result:

ok 1 number(s): "0"

Test #119:

score: 0
Accepted
time: 249ms
memory: 35720kb

input:

40
4 3 3 3 3 2 2 2 2 2 2 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
40
4 3 2 2 2 2 2 2 2 2 2 2 2 2 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
1000000

output:

126554390

result:

ok 1 number(s): "126554390"

Test #120:

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

input:

40
3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
40
4 4 2 2 2 2 2 2 2 2 2 2 2 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
352841

output:

0

result:

ok 1 number(s): "0"

Test #121:

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

input:

41
3 3 2 2 2 2 2 2 2 2 2 2 2 2 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
41
3 3 2 2 2 2 2 2 2 2 2 2 2 2 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
1000000

output:

986849858

result:

ok 1 number(s): "986849858"

Test #122:

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

input:

41
3 3 3 2 2 2 2 2 2 2 2 2 2 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
41
4 3 3 2 2 2 2 2 2 2 2 2 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
735060

output:

4969424

result:

ok 1 number(s): "4969424"

Test #123:

score: 0
Accepted
time: 238ms
memory: 34828kb

input:

42
3 2 2 2 2 2 2 2 2 2 2 2 2 2 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
42
3 3 2 2 2 2 2 2 2 2 2 2 2 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
1000000

output:

548917616

result:

ok 1 number(s): "548917616"

Test #124:

score: 0
Accepted
time: 218ms
memory: 31824kb

input:

42
4 3 2 2 2 2 2 2 2 2 2 2 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
42
3 3 2 2 2 2 2 2 2 2 2 2 2 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
893088

output:

330506349

result:

ok 1 number(s): "330506349"

Test #125:

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

input:

43
3 3 3 2 2 2 2 2 2 2 2 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
43
3 3 3 3 2 2 2 2 2 2 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
1000000

output:

538281356

result:

ok 1 number(s): "538281356"

Test #126:

score: 0
Accepted
time: 80ms
memory: 13156kb

input:

43
3 2 2 2 2 2 2 2 2 2 2 2 2 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
43
3 2 2 2 2 2 2 2 2 2 2 2 2 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
308011

output:

0

result:

ok 1 number(s): "0"

Test #127:

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

input:

44
3 2 2 2 2 2 2 2 2 2 2 2 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
44
2 2 2 2 2 2 2 2 2 2 2 2 2 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
1000000

output:

366977875

result:

ok 1 number(s): "366977875"

Test #128:

score: 0
Accepted
time: 106ms
memory: 17044kb

input:

44
2 2 2 2 2 2 2 2 2 2 2 2 2 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
44
3 2 2 2 2 2 2 2 2 2 2 2 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
433334

output:

341748216

result:

ok 1 number(s): "341748216"

Test #129:

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

input:

45
3 3 2 2 2 2 2 2 2 2 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
45
3 3 3 2 2 2 2 2 2 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
1000000

output:

177765364

result:

ok 1 number(s): "177765364"

Test #130:

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

input:

45
2 2 2 2 2 2 2 2 2 2 2 2 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
45
3 3 2 2 2 2 2 2 2 2 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
848258

output:

446654555

result:

ok 1 number(s): "446654555"

Test #131:

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

input:

46
2 2 2 2 2 2 2 2 2 2 2 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
46
4 2 2 2 2 2 2 2 2 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
1000000

output:

942939757

result:

ok 1 number(s): "942939757"

Test #132:

score: 0
Accepted
time: 60ms
memory: 10648kb

input:

46
3 2 2 2 2 2 2 2 2 2 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
46
2 2 2 2 2 2 2 2 2 2 2 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
230477

output:

0

result:

ok 1 number(s): "0"

Test #133:

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

input:

47
2 2 2 2 2 2 2 2 2 2 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
47
3 2 2 2 2 2 2 2 2 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
1000000

output:

799198307

result:

ok 1 number(s): "799198307"

Test #134:

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

input:

47
2 2 2 2 2 2 2 2 2 2 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
47
2 2 2 2 2 2 2 2 2 2 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
388505

output:

0

result:

ok 1 number(s): "0"

Test #135:

score: 0
Accepted
time: 244ms
memory: 34648kb

input:

48
2 2 2 2 2 2 2 2 2 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
48
2 2 2 2 2 2 2 2 2 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
1000000

output:

232111048

result:

ok 1 number(s): "232111048"

Test #136:

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

input:

48
2 2 2 2 2 2 2 2 2 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
48
2 2 2 2 2 2 2 2 2 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
803428

output:

113843582

result:

ok 1 number(s): "113843582"

Test #137:

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

input:

49
2 2 2 2 2 2 2 2 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
49
2 2 2 2 2 2 2 2 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
1000000

output:

680306711

result:

ok 1 number(s): "680306711"

Test #138:

score: 0
Accepted
time: 227ms
memory: 32464kb

input:

49
2 2 2 2 2 2 2 2 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
49
2 2 2 2 2 2 2 2 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
928752

output:

347231853

result:

ok 1 number(s): "347231853"

Test #139:

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

input:

50
2 2 2 2 2 2 2 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
50
2 2 2 2 2 2 2 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
1000000

output:

40117699

result:

ok 1 number(s): "40117699"

Test #140:

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

input:

50
3 2 2 2 2 2 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
50
2 2 2 2 2 2 2 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
152115

output:

0

result:

ok 1 number(s): "0"

Test #141:

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

input:

51
2 2 2 2 2 2 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
51
2 2 2 2 2 2 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
1000000

output:

548453254

result:

ok 1 number(s): "548453254"

Test #142:

score: 0
Accepted
time: 79ms
memory: 12956kb

input:

51
2 2 2 2 2 2 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
51
2 2 2 2 2 2 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
310142

output:

988289558

result:

ok 1 number(s): "988289558"

Test #143:

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

input:

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

output:

946424334

result:

ok 1 number(s): "946424334"

Test #144:

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

input:

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

output:

179671989

result:

ok 1 number(s): "179671989"

Test #145:

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

input:

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

output:

765916516

result:

ok 1 number(s): "765916516"

Test #146:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #147:

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

input:

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

output:

258348722

result:

ok 1 number(s): "258348722"

Test #148:

score: 0
Accepted
time: 67ms
memory: 11648kb

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #149:

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

input:

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

output:

31683532

result:

ok 1 number(s): "31683532"

Test #150:

score: 0
Accepted
time: 102ms
memory: 16516kb

input:

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

output:

190795051

result:

ok 1 number(s): "190795051"

Test #151:

score: 0
Accepted
time: 238ms
memory: 34396kb

input:

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

output:

492144789

result:

ok 1 number(s): "492144789"

Test #152:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #153:

score: 0
Accepted
time: 234ms
memory: 34508kb

input:

57
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 1 1 1 1 1 1 1 1 1 1 1
57
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 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

37995932

result:

ok 1 number(s): "37995932"

Test #154:

score: 0
Accepted
time: 230ms
memory: 33312kb

input:

57
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 1 1 1 1 1 1 1 1 1 1 1
57
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 1 1 1 1 1 1 1 1 1 1 1
963587

output:

0

result:

ok 1 number(s): "0"

Test #155:

score: 0
Accepted
time: 234ms
memory: 34576kb

input:

58
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 1 1 1 1 1 1 1 1 1 1 1 1 1
58
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 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

69508325

result:

ok 1 number(s): "69508325"

Test #156:

score: 0
Accepted
time: 95ms
memory: 15060kb

input:

58
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 1 1 1 1 1 1 1 1 1 1 1 1 1
58
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 1 1 1 1 1 1 1 1 1 1 1 1 1
378510

output:

728686682

result:

ok 1 number(s): "728686682"

Test #157:

score: 0
Accepted
time: 238ms
memory: 34384kb

input:

59
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
59
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
1000000

output:

901766304

result:

ok 1 number(s): "901766304"

Test #158:

score: 0
Accepted
time: 184ms
memory: 26984kb

input:

59
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
59
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
760730

output:

474839285

result:

ok 1 number(s): "474839285"

Test #159:

score: 0
Accepted
time: 241ms
memory: 34384kb

input:

60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1000000

output:

921463967

result:

ok 1 number(s): "921463967"

Test #160:

score: 0
Accepted
time: 175ms
memory: 25944kb

input:

60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
727197

output:

0

result:

ok 1 number(s): "0"