結果
| 問題 | No.2561 みんな大好きmod 998 |
| コンテスト | |
| ユーザー |
ロロット
|
| 提出日時 | 2026-01-25 12:18:17 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 4,000 ms |
| コード長 | 1,254 bytes |
| 記録 | |
| コンパイル時間 | 7,025 ms |
| コンパイル使用メモリ | 362,400 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2026-01-25 12:18:27 |
| 合計ジャッジ時間 | 9,266 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 44 |
ソースコード
#include <bits/stdc++.h>
#ifdef LOCAL
#include "utility/debug.hpp"
#else
#define debug(...)
#endif
using namespace std;
namespace rv = std::views; // NOLINT
// clang-format off
using lint = long long;
using P = pair<lint, lint>;
#define ALL(a) (a).begin(), (a).end()
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
inline void Yes(bool b = true) { println("{}",(b ? "Yes" : "No")); }
inline void No() { println("{}", "No");}
// clang-format on
/**/
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, K;
cin >> N >> K;
vector<lint> A(N);
for (auto&& a : A) cin >> a;
int ans = 0;
const lint MOD1 = 998;
const lint MOD2 = 998244353;
auto dfs = [&](this auto&& self, int depth, int last, lint sum) -> void {
if (depth == K) {
if (sum % MOD1 >= sum % MOD2) {
ans++;
if (ans >= 998) ans -= 998;
}
return;
}
for (int i = last + 1; i < N; i++) {
self(depth + 1, i, sum + A[i]);
}
};
dfs(0, -1, 0);
println("{}", ans);
}
ロロット