結果

問題 No.2561 みんな大好きmod 998
ユーザー gabriel55_gabriel55_
提出日時 2023-12-02 14:51:37
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 164 ms / 4,000 ms
コード長 1,997 bytes
コンパイル時間 4,175 ms
コンパイル使用メモリ 266,304 KB
実行使用メモリ 92,296 KB
最終ジャッジ日時 2024-09-26 17:34:01
合計ジャッジ時間 7,187 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

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