QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#312143 | #8150. XOR Sum | xiaolang# | WA | 1ms | 3952kb | C++14 | 1.6kb | 2024-01-23 14:13:46 | 2024-01-23 14:13:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,k;
const int N=1e3+5;
const int MOD=1e9+7;
int pp[N];
int can[N];
int t1[N];
int len=0;
map<pair<pair<int,int>,int >,int>mp;
int C[N][N];
int work(int bit,int rem,int cnt){
if(rem>=k/2*(k-k/2)*pp[bit+1])return 0;
if(rem<0)return 0;
if(bit==0){
int x=(m&1);
if(t1[rem]==-1)return 0;
if(x==0){
return (C[k-cnt][t1[rem]]+C[k-cnt][k-t1[rem]])%MOD;
}
else{
return C[k][t1[rem]]*2%MOD;
}
}
if(mp[make_pair(make_pair(bit,rem),cnt)])return mp[make_pair(make_pair(bit,rem),cnt)];
int x=(m&(pp[bit+1]-1));
int ans=0;
if(m&pp[bit]){
for(int i=0;i<=k;i++){
int limit=min(cnt,i);
int tt=can[min(i,k-i)]*pp[bit];
for(int j=0;j<=limit;j++){
//cout<<i<<" "<<j<<" "<<C[cnt][j]%MOD*C[k-cnt][i-j]%MOD<<"\n";
ans+=work(bit-1,rem-tt,j)*C[cnt][j]%MOD*C[k-cnt][i-j]%MOD;
ans%=MOD;
}
}
}
else{
for(int i=0;i<=k-cnt;i++){
int tt=can[min(i,k-i)]*pp[bit];
ans+=work(bit-1,rem-tt,cnt);
ans%=MOD;
}
}
mp[make_pair(make_pair(bit,rem),cnt)]=ans;
//cout<<bit<<" "<<rem<<" "<<cnt<<":"<<ans<<"\n";
return ans;
}
signed main(){
C[0][0]=1;
C[1][1]=1;
C[1][0]=1;
for(int i=2;i<=50;i++){
for(int j=0;j<=i;j++){
if(!j)C[i][j]=1;
else C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
//cout<<i<<" "<<j<<" "<<C[i][j]<<"\n";
}
}
pp[0]=1;
for(int i=1;i<=51;i++)pp[i]=pp[i-1]<<1;
scanf("%lld%lld%lld",&n,&m,&k);
for(int i=0;i<=k*k;i++)t1[i]=-1;
for(int i=0;i<=k/2;i++){
can[len++]=i*(k-i);
t1[i*(k-i)]=i;
}
cout<<work(50,n,k)<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3952kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3844kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3896kb
input:
0 0 1
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'