結果

問題 No.189 SUPER HAPPY DAY
ユーザー hirokazu1020hirokazu1020
提出日時 2015-04-22 01:22:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 1,157 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 76,092 KB
実行使用メモリ 8,348 KB
最終ジャッジ日時 2023-09-18 07:21:52
合計ジャッジ時間 1,705 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,476 KB
testcase_01 AC 2 ms
5,392 KB
testcase_02 AC 2 ms
5,364 KB
testcase_03 AC 2 ms
5,332 KB
testcase_04 AC 2 ms
5,388 KB
testcase_05 AC 2 ms
5,464 KB
testcase_06 AC 2 ms
5,404 KB
testcase_07 AC 3 ms
5,408 KB
testcase_08 AC 2 ms
5,332 KB
testcase_09 AC 2 ms
5,496 KB
testcase_10 AC 2 ms
5,416 KB
testcase_11 AC 2 ms
5,412 KB
testcase_12 AC 2 ms
5,320 KB
testcase_13 AC 7 ms
6,688 KB
testcase_14 AC 8 ms
7,232 KB
testcase_15 AC 8 ms
6,724 KB
testcase_16 AC 9 ms
6,748 KB
testcase_17 AC 10 ms
7,420 KB
testcase_18 AC 8 ms
6,664 KB
testcase_19 AC 11 ms
7,860 KB
testcase_20 AC 4 ms
5,820 KB
testcase_21 AC 5 ms
6,204 KB
testcase_22 AC 2 ms
5,540 KB
testcase_23 AC 9 ms
6,684 KB
testcase_24 AC 9 ms
6,976 KB
testcase_25 AC 16 ms
8,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())


#define MOD 1000000009


int dp1[202][2][2000];
int dp2[202][2][2000];

string m,d;

void f(int dp[202][2][2000],string &n){
	dp[0][0][0]=1;
	rep(i,n.size())rep(j,2)rep(k,2000)if(dp[i][j][k]){
		int v=dp[i][j][k];
		int md=(j==0?n[i]-'0':9)+1;
		rep(d,md){
			(dp[i+1][j||d<n[i]-'0'][k+d]+=v)%=MOD;
		}
	}
}


int main(){
	cin>>m>>d;
	f(dp1,m);
	f(dp2,d);
	long long ans=0;
	for(int i=1;i<2000;i++){
		ans+=(long long)dp1[m.size()][0][i]*dp2[d.size()][0][i]%MOD;
		ans+=(long long)dp1[m.size()][0][i]*dp2[d.size()][1][i]%MOD;
		ans+=(long long)dp1[m.size()][1][i]*dp2[d.size()][0][i]%MOD;
		ans+=(long long)dp1[m.size()][1][i]*dp2[d.size()][1][i]%MOD;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}
0