結果
| 問題 |
No.1753 Don't cheat.
|
| コンテスト | |
| ユーザー |
nok0
|
| 提出日時 | 2021-06-19 01:17:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 878 ms / 3,000 ms |
| コード長 | 1,113 bytes |
| コンパイル時間 | 2,237 ms |
| コンパイル使用メモリ | 201,400 KB |
| 最終ジャッジ日時 | 2025-01-22 09:54:30 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using mint = atcoder::modint998244353;
template <class T>
void fwt(std::vector<T> &f) {
int n = f.size();
for(int i = 1; i < n; i <<= 1) {
for(int j = 0; j < n; j++) {
if((j & i) == 0) {
T x = f[j], y = f[j | i];
f[j] = x + y, f[j | i] = x - y;
}
}
}
}
template <class T>
void ifwt(std::vector<T> &f) {
int n = f.size();
const T tinv = T(1) / 2;
for(int i = 1; i < n; i <<= 1) {
for(int j = 0; j < n; j++) {
if((j & i) == 0) {
T x = f[j], y = f[j | i];
f[j] = (x + y) * tinv, f[j | i] = (x - y) * tinv;
}
}
}
}
constexpr int sz = 1 << 11;
mint res;
int main() {
int n;
cin >> n;
std::vector<int> a(sz);
for(int i = 0; i <= n; i++) cin >> a[i];
int sum = accumulate(a.begin(), a.end(), 0);
vector<mint> f(sz);
f[0] = 1;
for(int i = 1; i < sz; i++) f[i] = -mint(a[i]) / sum;
for(int x = 1; x < sz; x++) {
auto g = f;
g[x] = 0;
fwt(g);
for(int i = 0; i < sz; i++) g[i] = g[i].inv();
ifwt(g);
res += g[x];
}
res *= a[0];
res /= sum;
cout << res.val() << endl;
return 0;
}
nok0