結果

問題 No.1753 Don't cheat.
ユーザー nok0nok0
提出日時 2021-06-19 01:17:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 740 ms / 3,000 ms
コード長 1,113 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 206,172 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 06:16:15
合計ジャッジ時間 28,364 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 736 ms
4,380 KB
testcase_01 AC 737 ms
4,376 KB
testcase_02 AC 738 ms
4,376 KB
testcase_03 AC 737 ms
4,380 KB
testcase_04 AC 736 ms
4,380 KB
testcase_05 AC 738 ms
4,384 KB
testcase_06 AC 736 ms
4,380 KB
testcase_07 AC 737 ms
4,380 KB
testcase_08 AC 736 ms
4,380 KB
testcase_09 AC 737 ms
4,376 KB
testcase_10 AC 736 ms
4,380 KB
testcase_11 AC 737 ms
4,380 KB
testcase_12 AC 736 ms
4,376 KB
testcase_13 AC 738 ms
4,380 KB
testcase_14 AC 739 ms
4,380 KB
testcase_15 AC 737 ms
4,380 KB
testcase_16 AC 737 ms
4,376 KB
testcase_17 AC 738 ms
4,380 KB
testcase_18 AC 737 ms
4,376 KB
testcase_19 AC 738 ms
4,376 KB
testcase_20 AC 737 ms
4,376 KB
testcase_21 AC 736 ms
4,380 KB
testcase_22 AC 737 ms
4,376 KB
testcase_23 AC 737 ms
4,380 KB
testcase_24 AC 736 ms
4,384 KB
testcase_25 AC 738 ms
4,380 KB
testcase_26 AC 740 ms
4,376 KB
testcase_27 AC 738 ms
4,376 KB
testcase_28 AC 737 ms
4,380 KB
testcase_29 AC 736 ms
4,376 KB
testcase_30 AC 736 ms
4,380 KB
testcase_31 AC 738 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0