QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#688066 | #8150. XOR Sum | wsxcb | AC ✓ | 126ms | 6684kb | C++17 | 1.3kb | 2024-10-29 23:05:13 | 2024-10-29 23:05:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
typedef vector<vector<ll>> Mat;
#define int long long
const int N=2000+10,mod=1e9+7,inf=1e9+1,P=998244353;
const double pi=acos(-1.0),esp=1e-9;
const ll INF=1e18;
int n,m,k,pw[50];
int C[50][50];
map<int,int>dp[50][20];
void add(int &x,int y){
x+=y;
if(x>mod)x-=mod;
}
int dfs(int now,int cnt,int sum){
if(now<0)return sum==0;
if(dp[now][cnt].count(sum))return dp[now][cnt][sum];
if(sum<0||(pw[now+1]-1)*(k/2)*(k-k/2)<sum)return 0;
int ans=0;
if((m>>now)&1)
{
for(int i=0;i<=cnt;i++)
for(int j=0;j<=k-cnt;j++)
add(ans,
C[cnt][i]*C[k-cnt][j]%mod*
dfs(now-1,i,sum-pw[now]*(i+j)*(k-i-j))%mod);
}
else
{
for(int i=0;i<=k-cnt;i++){
add(ans,C[k-cnt][i]*dfs(now-1,cnt,sum-pw[now]*i*(k-i))%mod);
}
}
dp[now][cnt][sum]=ans%mod;
return ans%mod;
}
void solve()
{
cin>>n>>m>>k;
C[0][0]=1;
pw[0]=1;
for(int i=1;i<50;i++)pw[i]=pw[i-1]*2;
for(int i=1;i<=k;i++){
C[i][0]=1;
for(int j=1;j<=i;j++)
C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
}
//cout<<(pw[41]-1)*(k/2)*(k-k/2)<<'\n';
cout<<dfs(40*1ll,k,n)%mod<<'\n';
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
while(t--)
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3696kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
0 0 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
0 0 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
0 1145141919 2
output:
145141913
result:
ok 1 number(s): "145141913"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
0 0 18
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
0 12412414 18
output:
12412415
result:
ok 1 number(s): "12412415"
Test #8:
score: 0
Accepted
time: 7ms
memory: 4336kb
input:
32071009996106 682053093123 12
output:
443207413
result:
ok 1 number(s): "443207413"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
35533005762427 688386210611 9
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 62ms
memory: 6572kb
input:
35533005762427 688386210611 18
output:
132815685
result:
ok 1 number(s): "132815685"
Test #11:
score: 0
Accepted
time: 126ms
memory: 6684kb
input:
12412412412412 549755813887 18
output:
769139144
result:
ok 1 number(s): "769139144"
Test #12:
score: 0
Accepted
time: 30ms
memory: 4876kb
input:
12412412412412 549755813887 17
output:
256540093
result:
ok 1 number(s): "256540093"
Test #13:
score: 0
Accepted
time: 18ms
memory: 4492kb
input:
12412412412412 549755813887 15
output:
661919152
result:
ok 1 number(s): "661919152"
Test #14:
score: 0
Accepted
time: 6ms
memory: 4320kb
input:
8213830533897 180838478436 12
output:
960275439
result:
ok 1 number(s): "960275439"
Test #15:
score: 0
Accepted
time: 58ms
memory: 6488kb
input:
8213830533897 180838478436 18
output:
794870059
result:
ok 1 number(s): "794870059"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
56737445336495 759179417237 12
output:
0
result:
ok 1 number(s): "0"
Test #17:
score: 0
Accepted
time: 57ms
memory: 6424kb
input:
56737445336495 759179417237 18
output:
302105482
result:
ok 1 number(s): "302105482"
Test #18:
score: 0
Accepted
time: 6ms
memory: 4320kb
input:
56737445336495 759179417237 15
output:
0
result:
ok 1 number(s): "0"
Test #19:
score: 0
Accepted
time: 7ms
memory: 4628kb
input:
12412412412412 274877906944 18
output:
430003400
result:
ok 1 number(s): "430003400"
Test #20:
score: 0
Accepted
time: 11ms
memory: 5588kb
input:
32412412412412 274877906944 18
output:
657686236
result:
ok 1 number(s): "657686236"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
562949953421311 549755813887 18
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3764kb
input:
985162418487295 549755813887 18
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
985162418487295 962072674303 18
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 125ms
memory: 6548kb
input:
35184372088831 962072674303 18
output:
665848241
result:
ok 1 number(s): "665848241"
Extra Test:
score: 0
Extra Test Passed