QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#688046#8150. XOR SumwsxcbRE 0ms0kbC++171.3kb2024-10-29 22:55:022024-10-29 22:55:02

Judging History

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

  • [2024-10-29 22:55:02]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-29 22:55:02]
  • 提交

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<=n;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: 0
Runtime Error

input:

6 2 3

output:


result: