QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#701831 | #8150. XOR Sum | HHAZ | TL | 1ms | 3960kb | C++20 | 2.8kb | 2024-11-02 14:47:06 | 2024-11-02 14:47:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
typedef pair<ld,ld>pdd;
typedef pair<ll, pair<ll, ll> > plpair;
typedef vector<int> vi;
typedef vector<ll> vl;
#define endl '\n'
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for(int i = (a); i >= (b); --i)
#define debug(x) cout<<#x<<": "<<x<<endl
#define lowbit(id) id & (-id)
#define fi first
#define sec second
#define lc id<<1
#define rc id<<1|1
#define sz(x) (int)(x).size()
#define all(t) (t).begin(), (t).end()
#define meh {cout<<"NO"<<endl;return;}
#define yay {cout<<"YES"<<endl;return;}
#define vin(v) for(auto&x:v)cin>>x;
#define print(v) for (auto x: v)cout<<x<<' ';cout<<endl;
#define sqrt(x) sqrtl(x)
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 2e3 + 5;
const ll M = 2e3 + 1;
const ll D = 101;
const ll mod = 1e9 + 7;
const ll MAX = 1e18;
ll c[20][20], a[65], id, n, m, k, pw2[65];
unordered_map<ll, ll>dp[65][20];
void init_combinatorial(ll Mod)
{
for(int i=0;i<19;i++) c[i][0]=1;
for(int i=1;i<19;i++)
{
for(int j=1;j<=i;j++)
{
c[i][j]=(c[i-1][j]+c[i-1][j-1])%Mod;
}
}
}
ll dfs(ll w, ll lim, ll need) {
if(w < 0) return (need == 0);
if(need < 0) return 0;
if(dp[w][lim].count(need)) return dp[w][lim][need];
ll ans = 0;
if(a[w]) {
rep(i, 0, lim) {
rep(j, 0, k - lim) {
ans += c[lim][i] * c[k - lim][j] % mod * dfs(w - 1, i, need - pw2[w] * (i + j) * (k - i - j)) % mod;
ans %= mod;
}
}
}
else {
rep(i, 0, k - lim) {
ans += c[k - lim][i] * dfs(w - 1, lim, need - pw2[w] * i * (k - i)) % mod;
ans %= mod;
}
}
dp[w][lim][need] = ans;
return ans;
}
void solve() {
init_combinatorial(mod);
pw2[0] = 1;
rep(i, 1, 60) {
pw2[i] = pw2[i - 1] * 2;
}
cin >> n >> m >> k;
while(m) {
a[id++] = m & 1;
m /= 2;
}
cout << dfs(id - 1, k, n) << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
// cin >> T;
// cout.flush();
// ofstream outfile("C:\\Users\\86187\\OneDrive\\桌面\\1.txt");
// outfile << "a[1]=0;a[2]=1;";
// ll l = 1e7 + 1;
// rep(i, 3, 1e9) {
// printf("%lld\n", i);
// ll x = (i - 1) * ((a[i - 1] + a[i - 2]) % mod);
// x %= mod;
// if(i == l) {
// outfile << "a[" << i << "]=" << x << ";";
// }
// if(i == l + 1) {
// outfile << "a[" << i << "]=" << x << ";";
// l += 1e7;
// }
// }
while(T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
input:
6 2 3
output:
12
result:
ok 1 number(s): "12"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
30 6 5
output:
1520
result:
ok 1 number(s): "1520"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
0 0 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
0 0 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3960kb
input:
0 1145141919 2
output:
145141913
result:
ok 1 number(s): "145141913"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
0 0 18
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
0 12412414 18
output:
12412415
result:
ok 1 number(s): "12412415"
Test #8:
score: -100
Time Limit Exceeded
input:
32071009996106 682053093123 12