結果

問題 No.2561 みんな大好きmod 998
ユーザー Peach2587Peach2587
提出日時 2023-12-02 15:05:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 268 ms / 4,000 ms
コード長 825 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 181,352 KB
実行使用メモリ 36,872 KB
最終ジャッジ日時 2023-12-02 15:05:47
合計ジャッジ時間 6,598 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 12 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 250 ms
36,872 KB
testcase_04 AC 247 ms
36,872 KB
testcase_05 AC 248 ms
36,872 KB
testcase_06 AC 268 ms
36,872 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 42 ms
8,144 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 248 ms
36,872 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 183 ms
36,872 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 1 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 57 ms
12,288 KB
testcase_27 AC 249 ms
36,872 KB
testcase_28 AC 75 ms
12,288 KB
testcase_29 AC 22 ms
6,676 KB
testcase_30 AC 61 ms
12,288 KB
testcase_31 AC 128 ms
20,484 KB
testcase_32 AC 34 ms
8,144 KB
testcase_33 AC 23 ms
6,676 KB
testcase_34 AC 249 ms
36,872 KB
testcase_35 AC 22 ms
6,676 KB
testcase_36 AC 21 ms
6,676 KB
testcase_37 AC 10 ms
6,676 KB
testcase_38 AC 42 ms
8,144 KB
testcase_39 AC 61 ms
12,288 KB
testcase_40 AC 61 ms
12,288 KB
testcase_41 AC 41 ms
8,144 KB
testcase_42 AC 75 ms
12,288 KB
testcase_43 AC 10 ms
6,676 KB
testcase_44 AC 30 ms
8,144 KB
testcase_45 AC 186 ms
36,872 KB
testcase_46 AC 27 ms
8,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/modint>
#include <atcoder/dsu>
#include <boost/rational.hpp>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
const double pi = 3.14159265359879323846264338327950288419;
const ll INF = 9 * 1e18;
using p = pair<ll, ll>;

int main() {
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<ll> tmp(n);
  for(int i = 0; i < k; i++) tmp[i]++;
  sort(tmp.begin(), tmp.end());
  
  vector<ll> v;
  do{
    ll sum = 0;
    for(int i = 0; i < n; i++){
      if(tmp[i]) sum += a[i];
    }
    v.push_back(sum);
  }while(next_permutation(tmp.begin(), tmp.end()));
  
  ll cnt = 0;
  for(auto x : v){
    if(x % 998244353 <= x % 998) cnt++;
  }
  
  cout << cnt % 998 << endl;
}
0