結果

問題 No.2561 みんな大好きmod 998
ユーザー may17may17
提出日時 2023-12-02 15:06:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 267 ms / 4,000 ms
コード長 625 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 207,032 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 15:06:49
合計ジャッジ時間 6,872 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 12 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 267 ms
6,676 KB
testcase_04 AC 251 ms
6,676 KB
testcase_05 AC 251 ms
6,676 KB
testcase_06 AC 251 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 42 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 250 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 184 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 56 ms
6,676 KB
testcase_27 AC 252 ms
6,676 KB
testcase_28 AC 75 ms
6,676 KB
testcase_29 AC 22 ms
6,676 KB
testcase_30 AC 64 ms
6,676 KB
testcase_31 AC 131 ms
6,676 KB
testcase_32 AC 32 ms
6,676 KB
testcase_33 AC 22 ms
6,676 KB
testcase_34 AC 251 ms
6,676 KB
testcase_35 AC 20 ms
6,676 KB
testcase_36 AC 20 ms
6,676 KB
testcase_37 AC 10 ms
6,676 KB
testcase_38 AC 41 ms
6,676 KB
testcase_39 AC 63 ms
6,676 KB
testcase_40 AC 63 ms
6,676 KB
testcase_41 AC 41 ms
6,676 KB
testcase_42 AC 74 ms
6,676 KB
testcase_43 AC 10 ms
6,676 KB
testcase_44 AC 30 ms
6,676 KB
testcase_45 AC 185 ms
6,676 KB
testcase_46 AC 25 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
//const ll mod = 1000000007;
const int mod = 998244353;
ll n, k, a[39];
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++)cin >> a[i];
	vector<int>v;
	for (int i = 1; i <= k; i++)v.push_back(1);
	for (int i = k + 1; i <= n; i++)v.push_back(0);
	sort(v.begin(), v.end());
	ll ans = 0;
	do {
		ll sum = 0;
		for (int i = 0; i < v.size(); i++) {
			if (v[i] == 1)sum += a[i + 1];
		}
		if (sum % mod <= sum % 998LL)ans++;
	} while (next_permutation(v.begin(), v.end()));
	cout << ans%998LL << endl;
}
0