QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#312161#8150. XOR Sumxiaolang#WA 20ms5924kbC++141.8kb2024-01-23 14:51:452024-01-23 14:51:45

Judging History

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

  • [2024-01-23 14:51:45]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:5924kb
  • [2024-01-23 14:51:45]
  • 提交

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){
	//cout<<bit<<" "<<rem<<" "<<cnt<<"\n";
	//cout<<"?\n";
	if(rem>k/2*(k-k/2)*(pp[bit+1]-1))return 0;
	if(rem<0)return 0;
	if(bit==0){
		int x=(m&1);
		if(t1[rem]==-1)return 0;
		if(x==0){
			if(t1[rem]*2!=k)return (C[k-cnt][t1[rem]]+C[k-cnt][k-t1[rem]])%MOD;
			else return C[k-cnt][t1[rem]];
		}
		else{
			if(t1[rem]*2!=k)return C[k][t1[rem]]*2%MOD;
			else return C[k][t1[rem]];
		}
	}
	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<=52;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])%MOD;
			//cout<<i<<" "<<j<<" "<<C[i][j]<<"\n"; 
		}
	}
	pp[0]=1;
	for(int i=1;i<=52;i++)pp[i]=pp[i-1]<<1;
	scanf("%lld%lld%lld",&n,&m,&k);
	if(k==1){
		cout<<(m+1)*(n==0)%MOD<<"\n";
		return 0;
	}
	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(45,n,k)<<"\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5924kb

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3988kb

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3968kb

input:

0 0 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3912kb

input:

0 0 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3860kb

input:

0 1145141919 2

output:

145141913

result:

ok 1 number(s): "145141913"

Test #6:

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

input:

0 0 18

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3932kb

input:

0 12412414 18

output:

12412415

result:

ok 1 number(s): "12412415"

Test #8:

score: -100
Wrong Answer
time: 20ms
memory: 4888kb

input:

32071009996106 682053093123 12

output:

240844115

result:

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