QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#621514 | #8150. XOR Sum | yangrun | WA | 1ms | 6044kb | C++17 | 1.6kb | 2024-10-08 15:04:32 | 2024-10-08 15:04:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define geti(x, i) (x >> (i - 1) & 1)
#define mod 1000000007
int read() {
int res = 0, flg = 1;
char c = getchar();
while(!isdigit(c)) {
if(c == '-') flg = 0;
c = getchar();
}
while(isdigit(c)) {
res = (res << 3) + (res << 1) + (c ^ 48);
c = getchar();
}
return flg ? res : -res;
}
const int N = 1e6 + 10, K = 20;
int n, m, k;
int dp[80][20][200], vis[80][20][200];
int c[K][K];
int dfs(int u, int lim, int cnt) {
if(u <= 0) return cnt == 0;
if(cnt >= 200) return 0;
if(vis[u][lim][cnt]) return dp[u][lim][cnt];
vis[u][lim][cnt] = 1;
int res = 0;
if(geti(n, u)) ++cnt;
if(geti(m, u)) {
for(int i = 0; i <= k; ++i) {
if(i * (k - i) > cnt) continue;
for(int j = max(0ll, i - (k - lim)); j <= lim && j <= i; ++j) {
res += c[lim][j] * c[k - lim][i - j] % mod * dfs(u - 1, j, (cnt - i * (k - i)) * 2) % mod;
res %= mod;
}
}
--cnt;
} else {
for(int i = 0; i <= k && i <= k - lim; ++i) {
if(i * (k - i) > cnt) continue;
res += c[k - lim][i] % mod * dfs(u - 1, lim, (cnt - i * (k - i)) * 2) % mod;
res %= mod;
}
}
if(geti(n, u)) --cnt;
//cout << u << ' ' << lim << ' ' << cnt << ' ' << res << '\n';
return dp[u][lim][cnt] = res;
}
signed main() {
n = read(), m = read(), k = read();
for(int i = 0; i <= k; ++i) {
for(int j = 0; j <= i; j++) {
if(j == 0 || j == i) c[i][j] = 1;
else c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
c[i][j] %= mod;
}
}
cout << dfs(60, k, 0) << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5932kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 1ms
memory: 4140kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 1ms
memory: 5976kb
input:
0 0 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 5848kb
input:
0 0 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 6044kb
input:
0 1145141919 2
output:
74814
result:
wrong answer 1st numbers differ - expected: '145141913', found: '74814'