結果
問題 | No.2561 みんな大好きmod 998 |
ユーザー |
![]() |
提出日時 | 2024-08-10 16:10:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 220 ms / 4,000 ms |
コード長 | 770 bytes |
コンパイル時間 | 2,997 ms |
コンパイル使用メモリ | 248,400 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-08-10 16:11:06 |
合計ジャッジ時間 | 7,105 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll = long long;#define rep(i,m,n) for(int i=m; i<n; ++i)#define repl(i,m,n) for(ll i=m; i<n; ++i)#define all(a) (a).begin(), (a).end()#define rall(a) (a).rbegin(), (a).rend()const ll mod1 = 998;const ll mod2 = 998244353;int main(){int N, K;cin >> N >> K;vector<ll> A(N);rep(i, 0, N) cin >> A[i];vector<int> per(N, 0);rep(i, 0, K){per[N-1-i] = 1;}ll ans = 0LL;do{ll S = 0LL;rep(i, 0, N){if(per[i]){S += A[i];}}ll S1 = S % mod1, S2 = S % mod2;if(S1 >= S2) ans++;ans %= mod1;}while(next_permutation(all(per)));cout << ans << endl;return 0;}