QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#505515#7609. ColonizationpandapythonerAC ✓183ms4008kbC++234.6kb2024-08-05 05:52:112024-08-05 05:52:11

Judging History

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

  • [2024-08-05 05:52:11]
  • 评测
  • 测评结果:AC
  • 用时:183ms
  • 内存:4008kb
  • [2024-08-05 05:52:11]
  • 提交

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 int maxn = 500;
const int max_rank = __lg(maxn + 1);
int n;
ll mod;
ll dp1[maxn + 1][max_rank + 1];
ll dp2[maxn + 1][max_rank + 1][3];
ll f[maxn + 1], invf[maxn + 1];
ll result[maxn + 1];

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


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


void add(ll& x, ll y) {
    x += y;
    if (x >= mod) x -= mod;
}


int32_t main() {
    if (1) {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    cin >> n;
    cin >> mod;
    memset(dp1, 0, sizeof(dp1));
    memset(dp2, 0, sizeof(dp2));
    memset(result, 0, sizeof(result));
    dp2[0][0][2] = 1;
    f[0] = invf[0] = 1;
    for (int i = 1; i <= n; i += 1) {
        f[i] = f[i - 1] * i % mod;
        invf[i] = inv(f[i]);
    }
    for (int tree_rank = 1; tree_rank <= max_rank; tree_rank += 1) {
        for (int tree_size = 1; tree_size <= n; tree_size += 1) {
            add(dp1[tree_size][tree_rank], dp2[tree_size - 1][tree_rank][0]);
            add(dp1[tree_size][tree_rank], dp2[tree_size - 1][tree_rank - 1][1]);
            add(dp1[tree_size][tree_rank], dp2[tree_size - 1][tree_rank - 1][2]);
            for (int sum_size = n; sum_size >= 1; sum_size -= 1) {
                ll val = 1;
                for (int k = 1; sum_size - k * tree_size >= 0; k += 1) {
                    val = val * (dp1[tree_size][tree_rank] + mod - 1 + k) % mod;
                    if (val == 0) break;
                    ll coeff = val * invf[k] % mod;
                    for (int old_max = 0; old_max <= tree_rank; old_max += 1) {
                        rep(count, 3) {
                            int new_count = min(2, k - 1 + (tree_rank == old_max ? count + 1 : 0));
                            add(dp2[sum_size][tree_rank][new_count],
                                dp2[sum_size - k * tree_size][old_max][count] * coeff % mod);
                        }
                    }
                }
            }

        }
    }
    for (int i = 1; i <= max_rank; i += 1) {
        add(result[i], dp2[n - 1][i - 1][2]);
    }
    for (int rank = 1; rank <= max_rank; rank += 1) {
        ll x = 0;
        auto get_super = [&](int size) {
            return (dp2[size - 1][rank - 1][1] + dp2[size - 1][rank - 1][2]) % mod;
            };
        vector<ll> dp(n + 1);
        for (int lsz = 1; lsz <= n; lsz += 1) {
            for (int rsz = 1; rsz + lsz <= n; rsz += 1) {
                add(dp[lsz + rsz], get_super(lsz) * get_super(rsz) % mod);
            }
        }
        for (int sz = 1; sz <= n; sz += 1) {
            for (int mx = 0; mx < rank; mx += 1) {
                for (int tsz = 1; sz - tsz > 0; tsz += 1) {
                    add(dp[sz], dp[sz - tsz] * dp2[tsz - 1][mx][0] % mod);
                    add(dp[sz], dp[sz - tsz] * dp2[tsz - 1][mx][1] % mod);
                    add(dp[sz], dp[sz - tsz] * dp2[tsz - 1][mx][2] % mod);
                }
            }
        }
        x = dp[n];
        vector<ll> dp_symm(n + 1);
        for (int lsz = 1; 2 * lsz <= n; lsz += 1) {
            add(dp_symm[2 * lsz], get_super(lsz));
        }
        for (int sz = 1; sz <= n; sz += 1) {
            for (int mx = 0; mx < rank; mx += 1) {
                for (int tsz = 1; sz - 2 * tsz > 0; tsz += 1) {
                    add(dp_symm[sz], dp_symm[sz - 2 * tsz] * dp2[tsz - 1][mx][0] % mod);
                    add(dp_symm[sz], dp_symm[sz - 2 * tsz] * dp2[tsz - 1][mx][1] % mod);
                    add(dp_symm[sz], dp_symm[sz - 2 * tsz] * dp2[tsz - 1][mx][2] % mod);
                }
            }
        }
        add(x, dp_symm[n]);
        for (int mid_size = 1; mid_size <= n; mid_size += 1) {
            ll count = 0;
            for (int mx = 0; mx < rank; mx += 1) {
                add(count, dp2[mid_size - 1][mx][0]);
                add(count, dp2[mid_size - 1][mx][1]);
                add(count, dp2[mid_size - 1][mx][2]);
            }
            add(x, count * dp_symm[n - mid_size] % mod);
        }
        x = x * inv(2) % mod;
        add(result[rank], x);
    }
    for (int i = 1; i <= n; i += 1) {
        cout << result[i] << " ";
    }
    cout << "\n";
    return 0;
}

/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 100000007

output:

1 0 0 

result:

ok 3 number(s): "1 0 0"

Test #2:

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

input:

6 300000007

output:

1 5 0 0 0 0 

result:

ok 6 numbers

Test #3:

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

input:

10 1000000007

output:

1 104 1 0 0 0 0 0 0 0 

result:

ok 10 numbers

Test #4:

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

input:

2 739878731

output:

1 0 

result:

ok 2 number(s): "1 0"

Test #5:

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

input:

3 122646779

output:

1 0 0 

result:

ok 3 number(s): "1 0 0"

Test #6:

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

input:

4 457287433

output:

1 1 0 0 

result:

ok 4 number(s): "1 1 0 0"

Test #7:

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

input:

5 1000000007

output:

1 2 0 0 0 

result:

ok 5 number(s): "1 2 0 0 0"

Test #8:

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

input:

6 1000000007

output:

1 5 0 0 0 0 

result:

ok 6 numbers

Test #9:

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

input:

7 763596907

output:

1 10 0 0 0 0 0 

result:

ok 7 numbers

Test #10:

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

input:

8 1000000007

output:

1 22 0 0 0 0 0 0 

result:

ok 8 numbers

Test #11:

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

input:

9 729507523

output:

1 46 0 0 0 0 0 0 0 

result:

ok 9 numbers

Test #12:

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

input:

11 488473873

output:

1 230 4 0 0 0 0 0 0 0 0 

result:

ok 11 numbers

Test #13:

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

input:

12 100000007

output:

1 531 19 0 0 0 0 0 0 0 0 0 

result:

ok 12 numbers

Test #14:

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

input:

13 1000000007

output:

1 1223 77 0 0 0 0 0 0 0 0 0 0 

result:

ok 13 numbers

Test #15:

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

input:

14 1000000007

output:

1 2871 287 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 14 numbers

Test #16:

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

input:

15 290707159

output:

1 6738 1002 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 15 numbers

Test #17:

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

input:

16 200746561

output:

1 15954 3365 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 16 numbers

Test #18:

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

input:

17 920695687

output:

1 37775 10853 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 17 numbers

Test #19:

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

input:

18 100000007

output:

1 89778 34088 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 18 numbers

Test #20:

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

input:

19 1000000007

output:

1 213380 104574 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 19 numbers

Test #21:

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

input:

20 1000000007

output:

1 507948 315116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 20 numbers

Test #22:

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

input:

21 1000000007

output:

1 1209183 935321 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 21 numbers

Test #23:

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

input:

22 293085943

output:

1 2880381 2743373 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 22 numbers

Test #24:

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

input:

23 1000000007

output:

1 6861350 7966717 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 23 numbers

Test #25:

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

input:

24 1000000007

output:

1 16348886 22950963 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 24 numbers

Test #26:

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

input:

25 100000007

output:

1 38955353 65681223 313 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 25 numbers

Test #27:

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

input:

31 534112939

output:

1 192268405 73638402 6451797 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 31 numbers

Test #28:

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

input:

32 1000000007

output:

1 5929365 938116336 28363756 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 32 numbers

Test #29:

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

input:

33 100000007

output:

1 28626901 79818017 20396526 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 33 numbers

Test #30:

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

input:

45 449530979

output:

1 171137267 404676218 400336656 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 45 numbers

Test #31:

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

input:

46 1000000007

output:

1 199174750 533156646 230095585 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 46 numbers

Test #32:

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

input:

63 901518881

output:

1 463582236 485174050 287704421 146635752 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 63 numbers

Test #33:

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

input:

64 137267147

output:

1 35160421 46570987 16058722 84291291 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 64 numbers

Test #34:

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

input:

65 285342521

output:

1 274680000 185520281 272194478 194410283 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 65 numbers

Test #35:

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

input:

93 927588749

output:

1 739012354 414231470 524375705 491769836 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 93 numbers

Test #36:

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

input:

94 1000000007

output:

1 174061321 12227912 673546067 414725694 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 94 numbers

Test #37:

score: 0
Accepted
time: 9ms
memory: 3688kb

input:

127 837565763

output:

1 446351899 736480797 801225275 81764442 837167518 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 127 numbers

Test #38:

score: 0
Accepted
time: 9ms
memory: 3700kb

input:

128 100000007

output:

1 53744379 39517387 95806759 76712174 64599518 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 128 numbers

Test #39:

score: 0
Accepted
time: 9ms
memory: 3972kb

input:

129 100000007

output:

1 54413572 77155852 35776158 8059026 50094475 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 

result:

ok 129 numbers

Test #40:

score: 0
Accepted
time: 20ms
memory: 3688kb

input:

189 100000007

output:

1 20631572 98966220 97206167 20535001 98542068 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 189 numbers

Test #41:

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

input:

190 1000000007

output:

1 860182239 85061792 915947137 663567155 838976700 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 190 numbers

Test #42:

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

input:

251 100000007

output:

1 44059658 9262465 26500589 1719804 86005028 93059166 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 251 numbers

Test #43:

score: 0
Accepted
time: 39ms
memory: 3692kb

input:

252 438884497

output:

1 350004178 339722925 331392720 339369500 346888489 145616211 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 252 numbers

Test #44:

score: 0
Accepted
time: 35ms
memory: 4008kb

input:

253 603030559

output:

1 271460264 113828285 211485995 140494699 117148110 528164491 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 253 numbers

Test #45:

score: 0
Accepted
time: 39ms
memory: 3772kb

input:

254 348935141

output:

1 43492722 336540922 302203252 295334615 232628368 334090063 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 254 numbers

Test #46:

score: 0
Accepted
time: 40ms
memory: 3688kb

input:

255 1000000007

output:

1 91921129 240703773 860507313 874767125 217480414 312302154 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 255 numbers

Test #47:

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

input:

256 1000000007

output:

1 53171383 308195745 292391229 411819088 716198819 576070511 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 256 numbers

Test #48:

score: 0
Accepted
time: 40ms
memory: 3776kb

input:

257 100000007

output:

1 81139239 17341218 77559815 79820516 8464002 98148398 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 257 numbers

Test #49:

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

input:

258 442383839

output:

1 17124647 269217418 150135508 44573661 331788565 178732642 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 258 numbers

Test #50:

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

input:

259 1000000007

output:

1 110221852 366165150 234264934 260805622 864063783 707330112 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 259 numbers

Test #51:

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

input:

260 712345379

output:

1 695448021 314265267 409389839 186491237 137959338 602047939 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 260 numbers

Test #52:

score: 0
Accepted
time: 42ms
memory: 3644kb

input:

261 905487833

output:

1 343672449 301480800 74963931 846427040 50121928 66712132 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 261 numbers

Test #53:

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

input:

379 785307437

output:

1 104449237 551856852 287086915 700424952 260302548 683038837 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 379 numbers

Test #54:

score: 0
Accepted
time: 98ms
memory: 3776kb

input:

380 1000000007

output:

1 898776986 792687672 458428823 424922724 540625189 703369531 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 380 numbers

Test #55:

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

input:

381 1000000007

output:

1 792757940 914747475 138265905 619378463 243945373 245237150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 381 numbers

Test #56:

score: 0
Accepted
time: 99ms
memory: 3672kb

input:

382 1000000007

output:

1 967586300 862777957 762030482 699420239 261107449 927966095 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 382 numbers

Test #57:

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

input:

383 215369873

output:

1 137773847 215004848 201659396 179799367 6430943 40328459 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 383 numbers

Test #58:

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

input:

384 1000000007

output:

1 507910674 458483513 431720627 483110084 435044603 540855576 369 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 384 numbers

Test #59:

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

input:

385 454793887

output:

1 248403036 291298368 251944296 296123869 371504911 24661638 8879 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 385 numbers

Test #60:

score: 0
Accepted
time: 101ms
memory: 3692kb

input:

386 1000000007

output:

1 265750215 79378345 232928900 483946141 205160466 429741317 202552 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 386 numbers

Test #61:

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

input:

387 227519269

output:

1 10763873 128932761 4923580 111935720 101016988 55107358 4366847 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 387 numbers

Test #62:

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

input:

388 1000000007

output:

1 958804227 524180264 304133528 240757407 115032333 782719263 89834392 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 388 numbers

Test #63:

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

input:

389 100000007

output:

1 1930815 57848302 3602158 77887435 14525348 1062339 70400721 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 389 numbers

Test #64:

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

input:

490 100000007

output:

1 96342386 17439556 23314154 89355902 37007860 13022516 15758638 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 490 numbers

Test #65:

score: 0
Accepted
time: 174ms
memory: 3756kb

input:

491 150073523

output:

1 9711255 122670986 90390709 18503883 27665285 140185636 116277727 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 491 numbers

Test #66:

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

input:

492 100000007

output:

1 53440278 34811222 65887674 39632523 80352836 51887989 53638950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 492 numbers

Test #67:

score: 0
Accepted
time: 176ms
memory: 3996kb

input:

493 1000000007

output:

1 744781325 335559402 899766846 495308909 483295651 260407300 970927089 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 493 numbers

Test #68:

score: 0
Accepted
time: 173ms
memory: 3756kb

input:

494 267940807

output:

1 173520076 91930068 196027436 182150385 254288786 233046355 184330491 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

result:

ok 494 numbers

Test #69:

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

input:

495 103825471

output:

1 103727223 64685514 91375652 39482044 46185280 83105809 50113222 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 495 numbers

Test #70:

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

input:

496 849169157

output:

1 344999439 495436786 781457946 404504956 270903993 494266348 209361467 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 496 numbers

Test #71:

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

input:

497 662520673

output:

1 156500838 639965771 190377618 568425495 81997 303944968 210618835 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 497 numbers

Test #72:

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

input:

498 1000000007

output:

1 573703418 935865068 977863365 602392352 835769495 352753836 613593614 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 498 numbers

Test #73:

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

input:

499 197518697

output:

1 183648021 12587187 141992294 103512133 121413153 142956322 51677789 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 499 numbers

Test #74:

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

input:

500 351956881

output:

1 278454371 270002440 87590952 340114688 136937620 87109359 224401059 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

ok 500 numbers

Extra Test:

score: 0
Extra Test Passed