結果
| 問題 | No.41 貯金箱の溜息(EASY) |
| コンテスト | |
| ユーザー |
myanta
|
| 提出日時 | 2017-05-04 23:03:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 644 bytes |
| 記録 | |
| コンパイル時間 | 547 ms |
| コンパイル使用メモリ | 41,600 KB |
| 実行使用メモリ | 16,160 KB |
| 最終ジャッジ日時 | 2024-09-14 07:18:06 |
| 合計ジャッジ時間 | 6,822 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | scanf("%d", &t);
| ~~~~~^~~~~~~~~~
main.cpp:55:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
55 | scanf("%lld", &m);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
using namespace std;
using ll=long long;
vector<vector<int> > dp;
ll mod(ll x)
{
return x%1000000009;
}
int min(int a, int b)
{
if(a<b) return a;
return b;
}
int solve(int md, int d)
{
int i, imax;
ll ret=0;
if(d==0) return 1;
if(dp[md][d]>=0) return dp[md][d];
imax=md/d;
for(i=0;i<=imax;i++)
{
ret+=solve(md-i*d, d-1);
}
return dp[md][d]=mod(ret);
}
int main(void)
{
int t;
dp.resize(90001);
for(int i=dp.size()-1;i>=0;i--) dp[i].resize(10, -1);
scanf("%d", &t);
for(int i=0;i<t;i++)
{
ll m;
scanf("%lld", &m);
printf("%d\n", solve(m/111111, 9));
}
return 0;
}
myanta