結果

問題 No.2062 Sum of Subset mod 999630629
ユーザー shobonvipshobonvip
提出日時 2022-08-26 23:43:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 893 bytes
コンパイル時間 5,028 ms
コンパイル使用メモリ 265,392 KB
実行使用メモリ 9,400 KB
最終ジャッジ日時 2024-04-22 01:49:43
合計ジャッジ時間 8,557 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 138 ms
9,216 KB
testcase_09 AC 109 ms
8,064 KB
testcase_10 AC 97 ms
7,704 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 130 ms
9,344 KB
testcase_24 AC 130 ms
9,344 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

int main(){
	// sum(A[i])はかなり小さいので, デカイやつは一周まわるので除外しまくる.
	int N;
	cin >> N;
	vector<int> A(N);
	
	mint ans = 0;
	mint nnv = mint(2).pow(N-1);
	queue<vector<mint>> Q;
	int asum = 0;

	for (int i=0; i<N; i++){
		cin >> A[i];
		ans += nnv * A[i];
		Q.push({A[i], 1});
		asum += A[i];
	}
	
	// これは多項式をマージするやつのテク O(N (log N)^2)
	while (Q.size() > 1){
		vector<mint> X = Q.front(); Q.pop();
		vector<mint> Y = Q.front(); Q.pop();
		Q.push(convolution<mint>(X, Y));
	}

	vector<mint> W = Q.front();
	mint jogai = 0;

	for (int i=0; i<=N; i++){
		if (asum - i >= 999630629){
			jogai += W[i];
		}
	}

	ans -= jogai * mint(999630629);
	cout << ans.val() << endl;

}
0