QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#312140#8150. XOR Sumxiaolang#WA 0ms3944kbC++141.6kb2024-01-23 14:09:282024-01-23 14:09:29

Judging History

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

  • [2024-01-23 14:09:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3944kb
  • [2024-01-23 14:09:28]
  • 提交

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<=40;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];
			//cout<<i<<" "<<j<<" "<<C[i][j]<<"\n"; 
		}
	}
	pp[0]=1;
	for(int i=1;i<=41;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(40,n,k)<<"\n";
	return 0;
}

詳細信息

Test #1:

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

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

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

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

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

input:

0 0 1

output:

0

result:

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