QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695866#8150. XOR SumMaxDYF#WA 0ms3920kbC++231.6kb2024-10-31 20:57:212024-10-31 20:57:23

Judging History

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

  • [2024-10-31 20:57:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3920kb
  • [2024-10-31 20:57:21]
  • 提交

answer

#include<stdio.h>
#include<string.h>
#include<unordered_map>
#include <bits/extc++.h>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int word;
typedef unsigned char byte;
struct READ{
	char c,w;
	inline READ(){c=getchar();}
	template<typename type>
	inline READ& operator>>(type &num){
		for(w=1;'0'>c||c>'9';c=getchar())
			w=c=='-'? -1:1;
		for(num=0;'0'<=c&&c<='9';c=getchar())
			num=num*10+(c-'0');
		return num*=w,*this;
	}
}cin;
const word mod=1e9+7;
ull n,m;
byte k;
word C[42][42];
std::unordered_map<ull,word> mp[42][20];
// dp[i][j][n] i 
int main(){
	cin>>n>>m>>k;
	mp[40][k][0]=1;
	C[0][0]=1;
	for(word n=1;n<=40;++n){
		C[n][0]=1;
		for(word m=1;m<=n;++m)
			C[n][m]=(C[n-1][m]+C[n-1][m-1])%mod;
	}
		
	for(word now=40;now--;) if(m>>now&1){
		for(word x=0;x<=k;++x)//x 个数贴着
			for(const auto &p:mp[now+1][x])
				for(word a=0;a<=k;++a){
					const ull nxt=p.first+(1ull*a*(k-a)<<now);
					if(nxt<=n&&n-nxt<(81<<now)) for(word y=0;y<=a&&y<=x;++y)//y个数为 1(仍然贴着)
						mp[now][y][nxt]=(1ull*C[x][y]*C[k-x][a-y]%mod
							*p.second+mp[now][y][nxt])%mod;
				}
	}else{
		for(word x=0;x<=k;++x)
			for(const auto &p:mp[now+1][x])
				for(word a=0;a<=k-x;++a){
					const ull nxt=p.first+(1ull*a*(k-a)<<now);
					if(nxt<=n&&n-nxt<(81<<now)) mp[now][x][nxt]=(
						1ull*C[k-x][a]*p.second+mp[now][x][nxt])%mod;
				}
	}
	ull ans=0;
	for(word x=0;x<=k;++x)
		ans+=mp[0][x][n];
	printf("%llu",ans%mod);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 2 3

output:

12

result:

ok 1 number(s): "12"

Test #2:

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

input:

30 6 5

output:

1520

result:

ok 1 number(s): "1520"

Test #3:

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

input:

0 0 1

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

0 0 2

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

0 1145141919 2

output:

145141913

result:

ok 1 number(s): "145141913"

Test #6:

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

input:

0 0 18

output:

1

result:

ok 1 number(s): "1"

Test #7:

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

input:

0 12412414 18

output:

12412415

result:

ok 1 number(s): "12412415"

Test #8:

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

input:

32071009996106 682053093123 12

output:

0

result:

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