結果
問題 |
No.2561 みんな大好きmod 998
|
ユーザー |
![]() |
提出日時 | 2023-12-03 23:01:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 276 ms / 4,000 ms |
コード長 | 835 bytes |
コンパイル時間 | 2,124 ms |
コンパイル使用メモリ | 198,076 KB |
最終ジャッジ日時 | 2025-02-18 06:55:47 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> cmb(n); for (int i = 0; i < k; i++) { cmb[i] = 1; } sort(cmb.begin(), cmb.end()); int ans = 0; do { int sum_998244 = 0, sum_998 = 0; for (int i = 0; i < n; i++) { if (cmb[i] == 1) { sum_998244 = (sum_998244 + a[i]) % 998244353; sum_998 = (sum_998 + a[i]) % 998; } } if (sum_998244 <= sum_998) { ans++; ans %= 998; } } while (next_permutation(cmb.begin(), cmb.end())); cout << ans << endl; }