,答案为 。
令 ,。
令 ,。
令 ,。其中 为将 中系数奇偶性满足条件的项的次数除以 得到的多项式。这样就可以递归下去。
答案即为 的常数项,其中 常数项显然为 。
#include <bits/stdc++.h>
using namespace std;
namespace z {
#define int long long
const int N = 5e5 + 5, mod = 998244353;
int n, s, t;
int a[22];
int f[62][42][402];
void main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
cin >> n >> s >> t;
for(int i = 1; i <= n; i++) cin >> a[i];
f[0][0][0] = 1;
for(int i = 0; i < 60; i++) {
for(int j = 1; j <= n; j++)
for(int x = 40; x >= 1; x--)
for(int y = 400; y >= a[j]; y--)
f[i][x][y] = (f[i][x][y] + f[i][x - 1][y - a[j]]) % mod;
for(int x = s & 1; x <= 40; x += 2)
for(int y = t & 1; y <= 400; y += 2)
f[i + 1][x >> 1][y >> 1] = f[i][x][y];
s >>= 1; t >>= 1;
}
cout << f[60][0][0] << '\n';
}
#undef int
}
int main()
{
z::main();
return 0;
}