QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#802699 | #8150. XOR Sum | Maxduan# | WA | 14ms | 6424kb | C++23 | 2.0kb | 2024-12-07 14:27:42 | 2024-12-07 14:27:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define maxn 100005
const int p=1e9+7;
int dp[70][1<<7][20];
int N[70],M[70];
vector<int>h[1<<7];
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<<7);u++){
if(dp[i][u][cnt]==0||u<v)continue;
int nxt=(u-v)*2+(i>0?N[i-1]:0);
if(nxt>=(1<<7))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();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 6224kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 0ms
memory: 5404kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 2ms
memory: 5924kb
input:
0 0 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 2ms
memory: 6288kb
input:
0 0 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 2ms
memory: 5516kb
input:
0 1145141919 2
output:
145141913
result:
ok 1 number(s): "145141913"
Test #6:
score: 0
Accepted
time: 4ms
memory: 5456kb
input:
0 0 18
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 3ms
memory: 6396kb
input:
0 12412414 18
output:
12412415
result:
ok 1 number(s): "12412415"
Test #8:
score: 0
Accepted
time: 3ms
memory: 6424kb
input:
32071009996106 682053093123 12
output:
443207413
result:
ok 1 number(s): "443207413"
Test #9:
score: 0
Accepted
time: 2ms
memory: 5208kb
input:
35533005762427 688386210611 9
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: -100
Wrong Answer
time: 14ms
memory: 6404kb
input:
35533005762427 688386210611 18
output:
243961557
result:
wrong answer 1st numbers differ - expected: '132815685', found: '243961557'