結果
| 問題 |
No.41 貯金箱の溜息(EASY)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-07-03 17:28:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 5,000 ms |
| コード長 | 1,705 bytes |
| コンパイル時間 | 1,312 ms |
| コンパイル使用メモリ | 166,904 KB |
| 実行使用メモリ | 23,872 KB |
| 最終ジャッジ日時 | 2024-10-05 12:28:52 |
| 合計ジャッジ時間 | 1,942 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
#include <bits/stdc++.h>
#define show(x) cout << #x << " = " << x << endl
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
os << "sz=" << v.size() << "\n[";
for (const auto& p : v) {
os << p << ",";
}
os << "]\n";
return os;
}
template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
os << "(" << p.first << "," << p.second
<< ")";
return os;
}
constexpr ll MOD = 1e9 + 9;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;
constexpr ll MAX = (10000000000 / 111111);
ll dp[10][MAX + 1]; // i番目まででy円
ll sum[10][MAX + 1];
ll summation[10][MAX + 1];
int main()
{
dp[0][0] = 1;
for (ll y = 0; y <= MAX; y++) {
sum[0][y] = 1;
}
for (ll i = 1; i <= 9; i++) {
for (ll y = 0; y <= MAX; y++) {
dp[i][y] = sum[i - 1][y];
if (y >= i + 1) {
sum[i][y] = (sum[i][y - (i + 1)] + dp[i][y]) % MOD;
} else {
sum[i][y] = dp[i][y];
}
if (y == 0) {
summation[i][y] = dp[i][y];
} else {
summation[i][y] = (summation[i][y - 1] + dp[i][y]) % MOD;
}
}
}
ll T;
cin >> T;
for (ll t = 0; t < T; t++) {
ll M;
cin >> M;
const ll m = M / 111111;
// ll sum = 0;
// for (ll y = 0; y <= m; y++) {
// sum = (sum + dp[9][y]) % MOD;
// }
// cout << sum << endl;
cout << summation[9][m] << endl;
}
return 0;
}