結果
問題 | No.2561 みんな大好きmod 998 |
ユーザー | may17 |
提出日時 | 2023-12-02 15:06:39 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 244 ms / 4,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 2,589 ms |
コンパイル使用メモリ | 205,320 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-26 18:04:42 |
合計ジャッジ時間 | 5,973 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 |
ソースコード
#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; }