問題一覧 > 通常問題

No.137 Chokinbako's Impatience

レベル : / AI推定難易度 : 2225 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 86
作問者 : hos.lyric
お気に入りにしたユーザー ProblemId : 192 / 自分の提出
問題文最終更新日: 2026-06-25 04:16:30
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 79 (順位表) の他の問題:

Problem Statement

Chokinbako lives in Country A. In this country, the unit of currency is called the yen, and $N$ kinds of coins are in use: $A_1$-yen coins, $A_2$-yen coins, …, $A_N$-yen coins.

Chokinbako has saved up coins over and over and now has $10^{100}$ coins of every kind. One day, Chokinbako is about to make a purchase of $M$ yen. However, the question "In how many ways can I pay exactly $M$ yen with the coins I have?" suddenly came to mind, and Chokinbako is too bothered by it to make the purchase.

Write a program that finds the number of ways for Chokinbako to pay exactly $M$ yen with coins, modulo $1{,}234{,}567{,}891$. $2$ ways of paying are considered the same if they use the same number of coins of every kind.

Input

$N$ $M$
$A_1$ $A_2$ $\cdots$ $A_N$
  • All input values are integers.
  • $1 \le N \le 50$.
  • $1 \le M \le 10^{18}$.
  • $1 \le A_1 < A_2 < \cdots < A_N \le 500$.

Output

Output on $1$ line the number of ways for Chokinbako to pay exactly $M$ yen with coins, modulo $1{,}234{,}567{,}891$.

Sample

Sample 1
Input
6 13
1 5 10 50 100 500
Output
4

The ways to pay $13$ yen are:

  • $13$ coins of $1$ yen
  • $8$ coins of $1$ yen and $1$ coin of $5$ yen
  • $3$ coins of $1$ yen and $2$ coins of $5$ yen
  • $3$ coins of $1$ yen and $1$ coin of $10$ yen
for a total of $4$ ways.

Sample 2
Input
2 2015
47 53
Output
0

It may be impossible to pay exactly $M$ yen.

Sample 3
Input
4 1000000000000000000
5 8 58 85
Output
48489055

Don't forget to take the remainder modulo $1{,}234{,}567{,}891$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。