結果
| 問題 |
No.2561 みんな大好きmod 998
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-24 18:05:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 393 ms / 4,000 ms |
| コード長 | 637 bytes |
| コンパイル時間 | 2,077 ms |
| コンパイル使用メモリ | 197,848 KB |
| 最終ジャッジ日時 | 2025-02-24 12:06:53 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)s; i < (int)e; i++)
int main() {
cin.tie(nullptr);
int N, K;
cin >> N >> K;
vector<ll> A(N);
rep(i, 0, N) cin >> A[i];
vector<bool> bit(N, false);
rep(i, N - K, N) bit[i] = true;
int ans = 0;
do {
ll sum = 0;
rep(i, 0, N) if (bit[i]) sum += A[i];
ll mod1 = sum % 998244353ll;
ll mod2 = sum % 998;
if (mod1 <= mod2) ans++;
} while (next_permutation(bit.begin(), bit.end()));
cout << ans % 998 << '\n';
}