結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー IL_mstaIL_msta
提出日時 2015-07-22 15:15:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 1,170 bytes
コンパイル時間 911 ms
コンパイル使用メモリ 85,020 KB
実行使用メモリ 9,840 KB
最終ジャッジ日時 2023-09-22 21:12:52
合計ジャッジ時間 1,457 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
9,840 KB
testcase_01 AC 20 ms
9,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
const int mod = 9+(int)1e9;
LL ans[10000];
const int dpmax = 100000;
LL dp[10][dpmax+1];

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(16);//
	int T;cin>>T;
	LL M;
	
	for(int i=0;i<=dpmax;++i){
		if(i-2>=0){
			dp[2][i] = (dp[2][i-2] + i + 1)%mod;
		}else{
			dp[2][i] = i + 1;
		}
	}

	for(int k=3;k<=9;++k)
	{
		for(int i=0;i<=dpmax;++i){
			if(i-k>=0){
				dp[k][i] = (dp[k][i-k] + dp[k-1][i])%mod;
			}else{
				dp[k][i] = dp[k-1][i];
			}
		}
	}
	
	rep(i,T){
		cin>>M;
		M /= 111111;
		ans[i] = dp[9][M];
	}
	rep(i,T){
		if(ans[i]){
			P(ans[i]);
		}else{
			P(1);
		}
	}
	
	return 0;
}
0