QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#695800 | #8150. XOR Sum | MaxDYF# | TL | 1ms | 4156kb | C++23 | 1.4kb | 2024-10-31 20:49:28 | 2024-10-31 20:49:29 |
Judging History
answer
#include<stdio.h>
#include<string.h>
#include<unordered_map>
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) 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) 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: 3788kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 0ms
memory: 4152kb
input:
0 0 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 4076kb
input:
0 0 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
0 1145141919 2
output:
145141913
result:
ok 1 number(s): "145141913"
Test #6:
score: 0
Accepted
time: 0ms
memory: 4156kb
input:
0 0 18
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
0 12412414 18
output:
12412415
result:
ok 1 number(s): "12412415"
Test #8:
score: -100
Time Limit Exceeded
input:
32071009996106 682053093123 12