QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#695847 | #8150. XOR Sum | MaxDYF# | WA | 1ms | 4292kb | C++23 | 1.5kb | 2024-10-31 20:54:52 | 2024-10-31 20:54:53 |
Judging History
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];
gp_hash_table<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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4052kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 1ms
memory: 4044kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 1ms
memory: 4292kb
input:
0 0 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 4004kb
input:
0 0 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
0 1145141919 2
output:
145141913
result:
ok 1 number(s): "145141913"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3992kb
input:
0 0 18
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 1ms
memory: 4292kb
input:
0 12412414 18
output:
12412415
result:
ok 1 number(s): "12412415"
Test #8:
score: -100
Wrong Answer
time: 1ms
memory: 4036kb
input:
32071009996106 682053093123 12
output:
0
result:
wrong answer 1st numbers differ - expected: '443207413', found: '0'