QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#695916 | #8150. XOR Sum | MaxDYF# | AC ✓ | 28ms | 6340kb | C++23 | 1.6kb | 2024-10-31 21:03:19 | 2024-10-31 21:03:45 |
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];
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<(81ull<<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<(81ull<<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;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4072kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 0ms
memory: 4076kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 0ms
memory: 4072kb
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: 3896kb
input:
0 1145141919 2
output:
145141913
result:
ok 1 number(s): "145141913"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
0 0 18
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
0 12412414 18
output:
12412415
result:
ok 1 number(s): "12412415"
Test #8:
score: 0
Accepted
time: 6ms
memory: 5292kb
input:
32071009996106 682053093123 12
output:
443207413
result:
ok 1 number(s): "443207413"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
35533005762427 688386210611 9
output:
0
result:
ok 1 number(s): "0"
Test #10:
score: 0
Accepted
time: 16ms
memory: 6188kb
input:
35533005762427 688386210611 18
output:
132815685
result:
ok 1 number(s): "132815685"
Test #11:
score: 0
Accepted
time: 28ms
memory: 6340kb
input:
12412412412412 549755813887 18
output:
769139144
result:
ok 1 number(s): "769139144"
Test #12:
score: 0
Accepted
time: 9ms
memory: 5104kb
input:
12412412412412 549755813887 17
output:
256540093
result:
ok 1 number(s): "256540093"
Test #13:
score: 0
Accepted
time: 6ms
memory: 4744kb
input:
12412412412412 549755813887 15
output:
661919152
result:
ok 1 number(s): "661919152"
Test #14:
score: 0
Accepted
time: 5ms
memory: 4936kb
input:
8213830533897 180838478436 12
output:
960275439
result:
ok 1 number(s): "960275439"
Test #15:
score: 0
Accepted
time: 11ms
memory: 5976kb
input:
8213830533897 180838478436 18
output:
794870059
result:
ok 1 number(s): "794870059"
Test #16:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
56737445336495 759179417237 12
output:
0
result:
ok 1 number(s): "0"
Test #17:
score: 0
Accepted
time: 11ms
memory: 5812kb
input:
56737445336495 759179417237 18
output:
302105482
result:
ok 1 number(s): "302105482"
Test #18:
score: 0
Accepted
time: 4ms
memory: 4504kb
input:
56737445336495 759179417237 15
output:
0
result:
ok 1 number(s): "0"
Test #19:
score: 0
Accepted
time: 7ms
memory: 5976kb
input:
12412412412412 274877906944 18
output:
430003400
result:
ok 1 number(s): "430003400"
Test #20:
score: 0
Accepted
time: 7ms
memory: 5724kb
input:
32412412412412 274877906944 18
output:
657686236
result:
ok 1 number(s): "657686236"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
562949953421311 549755813887 18
output:
0
result:
ok 1 number(s): "0"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
985162418487295 549755813887 18
output:
0
result:
ok 1 number(s): "0"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
985162418487295 962072674303 18
output:
0
result:
ok 1 number(s): "0"
Test #24:
score: 0
Accepted
time: 23ms
memory: 6000kb
input:
35184372088831 962072674303 18
output:
665848241
result:
ok 1 number(s): "665848241"
Extra Test:
score: 0
Extra Test Passed