QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#8925#1064. 移动金币Qingyu✨100 ✓2ms3744kbC++171.8kb2021-04-03 22:33:162021-12-19 11:07:20

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2021-12-19 11:07:20]
  • Judged
  • Verdict: 100
  • Time: 2ms
  • Memory: 3744kb
  • [2021-04-03 22:33:16]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define db double
#define mp make_pair
#define X first
#define Y second
#define vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<(a).size();++i)
#define gc getchar
inline ll rd()
{
    ll x = 0;
    char c = gc();

    while (!isdigit(c))
        c = gc();

    while (isdigit(c))
        x = x * 10 + c - 48, c = gc();

    return x;
}
const int N = 70, P = 1e9 + 9;
int n, m, fac[N], ifac[N], f[N][N], g[N];
inline int pw(int a, int b)
{
    int r = 1;

    for (; b; b >>= 1, a = 1ll * a * a % P)
        if (b & 1)
            r = 1ll * r * a % P;

    return r;
}
inline int C(int a, int b)
{
    return a >= b && b >= 0 ? 1ll * fac[a] * ifac[b] % P * ifac[a - b] % P : 0;
}
inline int sol(int n, int m)
{
    int o = m >> 1, e = m - o;
    f[18][0] = 1;

    rep(i, 0, m)for (int j = 0; j <= i; j += 2)
        g[i] = (g[i] + 1ll * C(o, j) * C(e, i - j)) % P;

    per(i, 17, 0)rep(j, 0, m)if (f[i + 1][j])
    {
        int t = (j * 2) + (n >> i & 1);

        for (int k = max(0, t - m); k <= m && k <= t; k++)
            f[i][t - k] = (f[i][t - k] + 1ll * f[i + 1][j] * g[k]) % P;
    }

    return f[0][0];
}
int main()
{
    n = rd();
    m = rd();
    fac[0] = 1;
    rep0(i, 1, N)fac[i] = 1ll * fac[i - 1] * i % P;
    ifac[N - 1] = pw(fac[N - 1], P - 2);
    per(i, N - 1, 1)ifac[i - 1] = 1ll * ifac[i] * i % P;
    int s = ifac[m];
    per(i, n, n - m + 1)s = 1ll * s * i % P;
    printf("%d\n", (s + P - sol(n - m, m + 1)) % P);
    return 0;
}

詳細信息

Subtask #1:

score: 50
Accepted

Test #1:

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

input:

242 49

output:

328585486

result:

ok single line: '328585486'

Test #2:

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

input:

242 47

output:

219114925

result:

ok single line: '219114925'

Test #3:

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

input:

243 50

output:

45372101

result:

ok single line: '45372101'

Test #4:

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

input:

243 47

output:

650410655

result:

ok single line: '650410655'

Test #5:

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

input:

244 47

output:

179262409

result:

ok single line: '179262409'

Test #6:

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

input:

245 50

output:

238336251

result:

ok single line: '238336251'

Test #7:

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

input:

245 48

output:

596598396

result:

ok single line: '596598396'

Test #8:

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

input:

246 46

output:

989539157

result:

ok single line: '989539157'

Test #9:

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

input:

246 46

output:

989539157

result:

ok single line: '989539157'

Test #10:

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

input:

240 50

output:

876085357

result:

ok single line: '876085357'

Subtask #2:

score: 50
Accepted

Test #11:

score: 50
Accepted
time: 2ms
memory: 3580kb

input:

142791 49

output:

83586215

result:

ok single line: '83586215'

Test #12:

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

input:

145417 47

output:

461460544

result:

ok single line: '461460544'

Test #13:

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

input:

148042 50

output:

990066474

result:

ok single line: '990066474'

Test #14:

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

input:

135668 50

output:

849717347

result:

ok single line: '849717347'

Test #15:

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

input:

138293 48

output:

605810507

result:

ok single line: '605810507'

Test #16:

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

input:

140919 46

output:

842694042

result:

ok single line: '842694042'

Test #17:

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

input:

143544 49

output:

806787086

result:

ok single line: '806787086'

Test #18:

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

input:

146170 49

output:

792539725

result:

ok single line: '792539725'

Test #19:

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

input:

148795 47

output:

445621354

result:

ok single line: '445621354'

Test #20:

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

input:

137925 48

output:

562018157

result:

ok single line: '562018157'