結果

問題 No.2561 みんな大好きmod 998
ユーザー gabriel55_gabriel55_
提出日時 2023-12-02 14:51:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 4,000 ms
コード長 1,997 bytes
コンパイル時間 3,839 ms
コンパイル使用メモリ 267,352 KB
実行使用メモリ 97,708 KB
最終ジャッジ日時 2023-12-02 14:51:51
合計ジャッジ時間 6,120 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 7 ms
7,336 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 92 ms
97,708 KB
testcase_04 AC 94 ms
97,708 KB
testcase_05 AC 91 ms
97,708 KB
testcase_06 AC 92 ms
97,708 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 1 ms
6,548 KB
testcase_11 AC 20 ms
18,728 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 94 ms
97,708 KB
testcase_16 AC 1 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 67 ms
70,376 KB
testcase_20 AC 1 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 26 ms
25,524 KB
testcase_27 AC 90 ms
97,708 KB
testcase_28 AC 30 ms
33,180 KB
testcase_29 AC 11 ms
10,576 KB
testcase_30 AC 26 ms
27,080 KB
testcase_31 AC 49 ms
53,744 KB
testcase_32 AC 15 ms
15,184 KB
testcase_33 AC 11 ms
10,576 KB
testcase_34 AC 92 ms
97,708 KB
testcase_35 AC 11 ms
10,064 KB
testcase_36 AC 10 ms
10,064 KB
testcase_37 AC 5 ms
6,548 KB
testcase_38 AC 19 ms
18,728 KB
testcase_39 AC 26 ms
27,080 KB
testcase_40 AC 28 ms
27,080 KB
testcase_41 AC 23 ms
18,728 KB
testcase_42 AC 30 ms
33,180 KB
testcase_43 AC 6 ms
6,548 KB
testcase_44 AC 16 ms
13,784 KB
testcase_45 AC 68 ms
70,376 KB
testcase_46 AC 12 ms
12,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#if !__INCLUDE_LEVEL__
#include __FILE__

const ll mod = 998244353;
const ll mod2 = 998;

int main() {
   ll n, k;
   cin >> n >> k;

   vector dp(k+1, vector<ll>());
   dp[0].emplace_back(0);

   vector<ll> a(n);
   rep(i,n) cin >> a[i];

   rep(i,n) {
      vector p = dp;
      swap(dp, p);
      rep(j,k) {
         for(auto &np : p[j]) {
            dp[j+1].emplace_back(np + a[i]);
         }
      }
   }
   ll ans = 0;
   for(auto &np : dp[k]) {
      if(np%mod <= np%mod2) ans++;
   }
   cout << ans%mod2 << '\n';
}

/*---------------------------------------------------------------------------------------------------
      ○______
       ||      |
       ||   ●   |
       ||      |
        || ̄ ̄ ̄ ̄ ̄
       ||  君が代は
   ∧__,,∧||  千代に八千代に
  ( `・ω・||    さざれ石の巌となりて
   ヽ  つ0     こけのむすまで
   し―-J
---------------------------------------------------------------------------------------------------*/

#else
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ldb = long double;
using P = pair<ll, ll>;
#define fi first
#define se second
#define m_99(i,a,b) for (ll i = a, i##_range = (b); i < i##_range; i++)
#define REP(i,a,b) m_99(i,a,b)
#define rep(i,a) m_99(i,0,a)
template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, true : false; }
template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, true : false; }
#ifdef _DEBUG
#include <debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif
struct initialise { initialise() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }__INI__;
const ll inf = 1LL << 60;
const ll dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1};
#endif
0