結果

問題 No.2561 みんな大好きmod 998
ユーザー norikame
提出日時 2023-12-03 18:22:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 452 ms / 4,000 ms
コード長 876 bytes
コンパイル時間 4,299 ms
コンパイル使用メモリ 251,004 KB
最終ジャッジ日時 2025-02-18 06:46:55
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

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

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);
const int mod1 = 998;
const int mod2 = 998244353;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<bool> ord(n);
	fill(ord.end()-k, ord.end(), true);
	int res = 0;
	do {
		int val1 = 0, val2 = 0;
		rep(i, n) if (ord[i]) {
			val1 = (val1 + a[i]) % mod1;
			val2 = (val2 + a[i]) % mod2;
		}
		if (val1 >= val2) res = (res + 1) % mod1;
	} while (next_permutation(all(ord)));
	cout << res << endl;
	return 0;
}
0