結果
| 問題 |
No.41 貯金箱の溜息(EASY)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-13 16:38:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 5,000 ms |
| コード長 | 724 bytes |
| コンパイル時間 | 577 ms |
| コンパイル使用メモリ | 69,724 KB |
| 実行使用メモリ | 6,940 KB |
| 最終ジャッジ日時 | 2024-09-13 10:18:08 |
| 合計ジャッジ時間 | 1,001 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
// 6桁硬貨の枚数を決めると1円硬貨の枚数は自動で決まる
// 額を111111で割った商を任意個の1~9を組み合わせて表す通り数
// をdpで求め、その累積和を取る
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 9;
int main(){
vector<ll> dp(90001, 0);
dp[0] = 1;
for(int i = 1; i <= 9; i++){
for(int j = 0; j+i < 90001; j++){
dp[j+i] += dp[j];
dp[j+i] %= mod;
}
}
for(int i = 1; i < 90001; i++) dp[i] += dp[i-1], dp[i] %= mod;
int t;
cin >> t;
ll m;
while(t-- > 0){
cin >> m;
cout << dp[m/111111ll] << endl;
}
return 0;
}