問題一覧 > 通常問題

No.42 The Piggy Bank's Sigh

レベル : / AI推定難易度 : 1900 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 73
作問者 : LayCurse
お気に入りにしたユーザー ProblemId : 22 / 自分の提出
問題文最終更新日: 2026-06-25 10:07:19
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 39 (順位表) の他の問題:

Problem Statement

Taro lives in Japan.
In this country, \(6\) types of coins are used: \(1\)-yen, \(5\)-yen, \(10\)-yen, \(50\)-yen, \(100\)-yen, and \(500\)-yen coins.

Piggy Bank has saved up coins over and over, and has at least \(10^{20}\) coins of each type: \(1\)-yen, \(5\)-yen, \(10\)-yen, \(50\)-yen, \(100\)-yen, and \(500\)-yen coins.
However, Taro wanted to go shopping for \(M\) yen.
Taro asked Piggy Bank to give him coins totaling exactly \(M\) yen.
Reluctant to give away the coins he had worked so hard to save, Piggy Bank decided to give them only if Taro could answer a question.
Piggy Bank asked, "What is the minimum number of coins I must hand over to give you \(M\) yen?", but Taro answered instantly.
So, with \(1\) more question, Piggy Bank switched to this one: "How many ways are there for me to hand over coins to give you \(M\) yen?"
This time, Taro was stuck.
Write a program that finds the number of ways Piggy Bank can give \(M\) yen to Taro, modulo \(10^9+9\).

Input

\(T\)
\(M_1\)
\(M_2\)
\(\vdots\)
\(M_T\)

\(1 \leq T \leq 10000\) represents the number of test cases.
\(1 \leq M_k \leq 10^{18}\) represents the value of \(M\) in each test case.

Output

On the \(k\)-th line of the output, print the number of ways Piggy Bank can give \(M_k\) yen to Taro, modulo \(10^9+9\).

Sample

Sample 1
Input
4
10
100
1000000000
1000000000000000000
Output
4
159
248167937
266325766

The ways to give \(10\) yen are:
・\(10\) coins of \(1\) yen
・\(5\) coins of \(1\) yen and \(1\) coin of \(5\) yen
・\(2\) coins of \(5\) yen
・\(1\) coin of \(10\) yen
for a total of \(4\) ways.

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