結果

問題 No.137 貯金箱の焦り
ユーザー Ryuhei MoriRyuhei Mori
提出日時 2022-07-29 04:20:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 760 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 75,000 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 23:21:30
合計ジャッジ時間 2,103 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 91 ms
4,376 KB
testcase_13 AC 7 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using u32 = unsigned int;
using u64 = unsigned long long int;

constexpr u32 mod = 1234567891;
std::vector<u32> A;

int main(){
  u32 n;
  u64 m;
  std::cin >> n >> m;
  for(u32 i = 0; i < n; i++){
    u32 x;
    std::cin >> x;
    A.push_back(x);
  }

  std::vector<u32> num(2*50*500);
  num[0] = 1;
  u32 deg = 0;
  for(; m; m >>= 1){
    for(u32 &a: A){
      if(a & 1){
        deg += a;
        for(u32 i = deg; i >= a; i--){
          num[i] += num[i-a];
          if(num[i] >= mod) num[i] -= mod;
        }
      }
      else a >>= 1;
    }
    for(u32 i = m & 1; i <= deg; i += 2) num[i/2] = num[i];
    for(u32 i = deg/2 + 1; i <= deg; i++) num[i] = 0;
    deg >>= 1;
  }
  printf("%u\n", num[0]);
  return 0;
}
0