QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575769#8150. XOR SumzxzxzxqTL 334ms8228kbC++141.5kb2024-09-19 16:42:472024-09-19 16:42:49

Judging History

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

  • [2024-09-19 16:42:49]
  • 评测
  • 测评结果:TL
  • 用时:334ms
  • 内存:8228kb
  • [2024-09-19 16:42:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define int long long

const int maxn = 110;
const int mod = 1e9 + 7;
int jc[maxn],upm[maxn],ans;
int f[maxn][350][20];

int powe(int a, int b) {
    int base = 1;
    while(b) {
        if(b & 1) base = base * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return base;
}

int c(int n, int m) {
    return jc[n] * powe(jc[m], mod - 2) % mod * powe(jc[n - m], mod - 2) % mod;
}

signed main() {
    // freopen("data.in", "r", stdin);
    int n, m, k;
    cin >> n >> m >> k;
    f[61][0][k]=1;
    jc[0]=1;
    for(int i=1;i<=20;i++) jc[i]=jc[i-1]*i%mod;
    for(int i=60;i>=0;i--)
    {
        int now=1ll<<i;
        int lk=(n&now)!=0;
        for(int j=0;j<=k*k/2;j++)
        for(int w=0;w<=k;w++)
        for(int a=0;a<=k-w;a++)
        {
            if(now&m)
            {
                for(int b=0;b<=w;b++)
                {
                    int nowj=j*2+lk-(k-a-b)*(a+b);
                    if(nowj<0) continue;
                    f[i][nowj][b]=(f[i][nowj][b]+f[i+1][j][w]*c(k-w,a)%mod*c(w,b))%mod;
                }
            }
            else
            {
                int nowj=j*2+lk-(k-a)*a;
                if(nowj<0) continue;
                f[i][nowj][w]=(f[i][nowj][w]+f[i+1][j][w]*c(k-w,a))%mod;
                // if(i==60)cout<<f[i][nowj][w]<<'\n';
            }
        }
    }
    for(int i=0;i<=k;i++) ans+=f[0][0][i];
    cout<<ans%mod<<'\n';
    return 0;
}

详细

Test #1:

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

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

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

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

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

input:

0 0 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

0 0 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

0 1145141919 2

output:

145141913

result:

ok 1 number(s): "145141913"

Test #6:

score: 0
Accepted
time: 334ms
memory: 8228kb

input:

0 0 18

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: -100
Time Limit Exceeded

input:

0 12412414 18

output:


result: