QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#802717 | #8150. XOR Sum | Maxduan | AC ✓ | 46ms | 8296kb | C++23 | 2.0kb | 2024-12-07 14:29:52 | 2024-12-07 14:29:53 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 100005
const int p=1e9+7;
int dp[80][1<<8][20];
int N[80],M[80];
vector<int>h[1<<8];
int fac[maxn],inv[maxn];
int qpow(int a,int b){
int ans=1;
int tmp=a;
while(b){
if(b&1){
ans=ans*tmp%p;
}
tmp=tmp*tmp%p;
b>>=1;
}
return ans;
}
int C(int a,int b){
if (a < b) return 0;
return fac[a]*inv[b]%p*inv[a-b]%p;
}
void solve(){
int n,m,k;cin>>n>>m>>k;
for(int i=60;i>=0;i--){
N[i]=(n>>i&1);
M[i]=(m>>i&1);
}
dp[60][0][k]=1;
int ans=0;
for(int i=60;i>=0;i--){
for(int x=0;x<=k;x++){
int y=k-x;
int v=x*y;
for(int cnt=0;cnt<=k;cnt++){
for(int u=0;u<(1<<8);u++){
if(dp[i][u][cnt]==0||u<v)continue;
int nxt=(u-v)*2+(i>0?N[i-1]:0);
if(nxt>=(1<<8))continue;
for(int cnt2=0;cnt2<=cnt;cnt2++){
if(M[i]==0&&cnt2!=cnt)continue;
if(cnt-cnt2<=y){
int tp=C(k-cnt,y-cnt+cnt2)*C(cnt,cnt2)%p;
if(i>0){
dp[i-1][nxt][cnt2]+=dp[i][u][cnt]*tp%p;
if(dp[i-1][nxt][cnt2]>=p)dp[i-1][nxt][cnt2]-=p;
}
else if(nxt==0){
ans+=dp[i][u][cnt]*tp%p;
}
}
}
}
}
}
}
cout<<ans%p;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
fac[0]=1;
for(int i=1;i<maxn;i++){
fac[i]=fac[i-1]*i%p;
}
inv[maxn-1]=qpow(fac[maxn-1],p-2);
for(int i=maxn-2;i>=0;i--){
inv[i]=inv[i+1]*(i+1)%p;
}
solve();
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 6756kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 2ms
memory: 5392kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 2ms
memory: 7304kb
input:
0 0 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 2ms
memory: 6564kb
input:
0 0 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 2ms
memory: 7856kb
input:
0 1145141919 2
output:
145141913
result:
ok 1 number(s): "145141913"
Test #6:
score: 0
Accepted
time: 6ms
memory: 6760kb
input:
0 0 18
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 5ms
memory: 5388kb
input:
0 12412414 18
output:
12412415
result:
ok 1 number(s): "12412415"
Test #8:
score: 0
Accepted
time: 11ms
memory: 6832kb
input:
32071009996106 682053093123 12
output:
443207413
result:
ok 1 number(s): "443207413"
Test #9:
score: 0
Accepted
time: 3ms
memory: 8120kb
input:
35533005762427 688386210611 9
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 26ms
memory: 6856kb
input:
35533005762427 688386210611 18
output:
132815685
result:
ok 1 number(s): "132815685"
Test #11:
score: 0
Accepted
time: 44ms
memory: 6948kb
input:
12412412412412 549755813887 18
output:
769139144
result:
ok 1 number(s): "769139144"
Test #12:
score: 0
Accepted
time: 23ms
memory: 7196kb
input:
12412412412412 549755813887 17
output:
256540093
result:
ok 1 number(s): "256540093"
Test #13:
score: 0
Accepted
time: 14ms
memory: 6868kb
input:
12412412412412 549755813887 15
output:
661919152
result:
ok 1 number(s): "661919152"
Test #14:
score: 0
Accepted
time: 10ms
memory: 7632kb
input:
8213830533897 180838478436 12
output:
960275439
result:
ok 1 number(s): "960275439"
Test #15:
score: 0
Accepted
time: 24ms
memory: 7092kb
input:
8213830533897 180838478436 18
output:
794870059
result:
ok 1 number(s): "794870059"
Test #16:
score: 0
Accepted
time: 4ms
memory: 7812kb
input:
56737445336495 759179417237 12
output:
0
result:
ok 1 number(s): "0"
Test #17:
score: 0
Accepted
time: 27ms
memory: 6888kb
input:
56737445336495 759179417237 18
output:
302105482
result:
ok 1 number(s): "302105482"
Test #18:
score: 0
Accepted
time: 10ms
memory: 6984kb
input:
56737445336495 759179417237 15
output:
0
result:
ok 1 number(s): "0"
Test #19:
score: 0
Accepted
time: 6ms
memory: 6796kb
input:
12412412412412 274877906944 18
output:
430003400
result:
ok 1 number(s): "430003400"
Test #20:
score: 0
Accepted
time: 13ms
memory: 7060kb
input:
32412412412412 274877906944 18
output:
657686236
result:
ok 1 number(s): "657686236"
Test #21:
score: 0
Accepted
time: 6ms
memory: 8296kb
input:
562949953421311 549755813887 18
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 6ms
memory: 5340kb
input:
985162418487295 549755813887 18
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 6ms
memory: 7052kb
input:
985162418487295 962072674303 18
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 46ms
memory: 7972kb
input:
35184372088831 962072674303 18
output:
665848241
result:
ok 1 number(s): "665848241"
Extra Test:
score: 0
Extra Test Passed