QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#665857#8150. XOR SumqdsdsyWA 3ms2648kbC++202.9kb2024-10-22 15:35:492024-10-22 15:35:49

Judging History

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

  • [2024-10-22 15:35:49]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:2648kb
  • [2024-10-22 15:35:49]
  • 提交

answer

#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;

const int mo=1000000007;
ll n,k;
ll m;
int cm,cn;
int bm[64],bn[64];
int C[20][20];
int f[50][1<<7][20][2];

int getn(int l,int r){
	l--,r--;
	return n>>l&((1ll<<(r-l+1))-1); 
}
int main()
{
	scanf("%lld%lld%d",&n,&m,&k);
	// printf("%d\n",getn(1,3));

	C[0][0]=1;
	for(int i=1;i<=k;i++){
		C[i][0]=1;
		for(int j=1;j<=k;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}

	while(m){
		bm[++cm]=m&1ll;
		m>>=1ll;
	}
	ll n1=n;
	while(n1){
		bn[++cn]=n1&1ll;
		// printf("! %d\n",n1&1ll);
		n1>>=1ll;
		// printf("!! %d\n",n1);
	}
	memset(f,0,sizeof(f));
	f[cm+1][0][k][0]=1;

	for(int i=cm+1;i>1;i--){
		for(int j=0;j<(1<<7);j++){
			for(int t=0;t<=k;t++){
				// if(i==2 && j==0 && t==0)
				// 	printf("?\n");
				if(!f[i][j][t][0] && !f[i][j][t][1]) continue;
				// if(i==2 && j==0 && t==0)
				// 	printf("?\n");
				if(bm[i-1]==0){
					for(int d=0;d<=k-t;d++){
						int s=d*(k-d);
						int s1=((j<<1)+s);
						int p=s1&127, q=s1>>7, c=s1>>8;
						ll v1=1ll*f[i][j][t][1]*C[k-t][d]%mo, v0=1ll*f[i][j][t][0]*C[k-t][d]%mo;
						if(p>getn(i-1,i+5)){
							if((c==0 && q==1 && bn[i+6]==0) || (c==1 && q==0 && bn[i+6]==1))
								f[i-1][p][t][1]=(f[i-1][p][t][1]+v1)%mo;
						}else {
							if(c==1){
								if(q<=bn[i+6]){
									if(q==0 && bn[i+6]==1) f[i-1][p][t][1]=(f[i-1][p][t][1]+v1)%mo;
									else f[i-1][p][t][0]=(f[i-1][p][t][0]+v1)%mo;
								}
							}else {
								if(q==1 && bn[i+6]==0) f[i-1][p][t][1]=(f[i-1][p][t][1]+v1)%mo;
								else if(q==0 && bn[i+6]==1) f[i-1][p][t][1]=(f[i-1][p][t][1]+v0)%mo;
								else f[i-1][p][t][0]=(f[i-1][p][t][0]+v0)%mo; 
							}
						}
					}
				}else {
					for(int d=0;d<=k;d++){
						int s=d*(k-d);
						int s1=((j<<1)+s);
						int p=s1&127, q=s1>>7, c=s1>>8;
						// if(q==1 || c==1)
						// 	printf("error\n");
						for(int e=0;e<=min(d,t);e++){
							ll v0=1ll*f[i][j][t][0]*C[t][e]%mo*C[k-t][d-e]%mo;
							ll v1=1ll*f[i][j][t][1]*C[t][e]%mo*C[k-t][d-e]%mo;
							// if(t==0 && e==0 && i==2 && j==0){
							// 	printf("!! s1=%d p=%d q=%d c=%d\n",s1,p,q,c);
							// }
							if(p>getn(i-1,i+5)){
								if((c==0 && q==1 && bn[i+6]==0) || (c==1 && q==0 && bn[i+6]==1))
									f[i-1][p][e][1]=(f[i-1][p][e][1]+v1)%mo;
							}else {
								if(c==1){
									if(q<=bn[i+6]){
										if(q==0 && bn[i+6]==1) f[i-1][p][e][1]=(f[i-1][p][e][1]+v1)%mo;
										else f[i-1][p][e][0]=(f[i-1][p][e][0]+v1)%mo;
									}
								}else {
									if(q==1 && bn[i+6]==0) f[i-1][p][e][1]=(f[i-1][p][e][1]+v1)%mo;
									else if(q==0 && bn[i+6]==1) f[i-1][p][e][1]=(f[i-1][p][e][1]+v0)%mo;
									else f[i-1][p][e][0]=(f[i-1][p][e][0]+v0)%mo; 
								}
							}
						}
					}
				}
			}
		}
	}

	ll ans=0;
	for(int t=0;t<=k;t++)
		ans=(ans+f[1][getn(1,7)][t][0])%mo;
	printf("%lld\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

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

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

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

input:

0 0 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

0 0 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

0 1145141919 2

output:

145141913

result:

ok 1 number(s): "145141913"

Test #6:

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

input:

0 0 18

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

0 12412414 18

output:

12412415

result:

ok 1 number(s): "12412415"

Test #8:

score: -100
Wrong Answer
time: 3ms
memory: 2540kb

input:

32071009996106 682053093123 12

output:

827137534

result:

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