QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#688047#8150. XOR SumwsxcbWA 0ms3768kbC++171.3kb2024-10-29 22:55:482024-10-29 22:55:49

Judging History

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

  • [2024-10-29 22:55:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3768kb
  • [2024-10-29 22:55:48]
  • 提交

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){
	
	//cout<<now<<' '<<sum<<'\n';
	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;
	
	return ans;
}
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%mod;
	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<<dfs(40,k,n)<<'\n';
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3716kb

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

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

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

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

input:

0 0 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

0 0 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

0 1145141919 2

output:

145141913

result:

ok 1 number(s): "145141913"

Test #6:

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

input:

0 0 18

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

0 12412414 18

output:

12412415

result:

ok 1 number(s): "12412415"

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3760kb

input:

32071009996106 682053093123 12

output:

0

result:

wrong answer 1st numbers differ - expected: '443207413', found: '0'