結果

問題 No.189 SUPER HAPPY DAY
ユーザー 👑 kmjpkmjp
提出日時 2015-04-22 00:44:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 1,283 bytes
コンパイル時間 3,321 ms
コンパイル使用メモリ 156,328 KB
実行使用メモリ 7,004 KB
最終ジャッジ日時 2023-09-18 05:39:35
合計ジャッジ時間 6,366 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
6,584 KB
testcase_01 AC 48 ms
6,580 KB
testcase_02 AC 48 ms
6,588 KB
testcase_03 AC 48 ms
6,600 KB
testcase_04 AC 48 ms
6,660 KB
testcase_05 AC 48 ms
6,740 KB
testcase_06 AC 48 ms
6,580 KB
testcase_07 AC 48 ms
6,604 KB
testcase_08 AC 48 ms
6,888 KB
testcase_09 AC 48 ms
6,600 KB
testcase_10 AC 48 ms
6,580 KB
testcase_11 AC 48 ms
6,860 KB
testcase_12 AC 48 ms
6,652 KB
testcase_13 AC 71 ms
6,736 KB
testcase_14 AC 83 ms
7,004 KB
testcase_15 AC 91 ms
6,704 KB
testcase_16 AC 96 ms
6,700 KB
testcase_17 AC 100 ms
6,792 KB
testcase_18 AC 84 ms
6,716 KB
testcase_19 AC 102 ms
6,800 KB
testcase_20 AC 60 ms
6,740 KB
testcase_21 AC 59 ms
6,700 KB
testcase_22 AC 48 ms
6,620 KB
testcase_23 AC 48 ms
6,700 KB
testcase_24 AC 48 ms
6,824 KB
testcase_25 AC 48 ms
6,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string M,D;
ll mo=1000000009;

map<int,ll> enumdigsum(string S) {
	static ll dp[205][2050];
	int tot=0,i,x,y;
	map<int,ll> R;
	
	if(dp[0][0]==0) {
		dp[0][0]=1;
		FOR(i,202) FOR(y,2000) FOR(x,10) (dp[i+1][y+x]+=dp[i][y])%=mo;
	}
	
	reverse(S.begin(),S.end());
	while(S.size()) {
		int x=S[S.size()-1]-'0';
		FOR(i,x) FOR(y,2020) if(dp[S.size()-1][y]) (R[y+tot+i] += dp[S.size()-1][y])%=mo;
		tot+=x;
		S.pop_back();
	}
	R[tot]++;
	return R;
}

void solve() {
	
	cin>>M>>D;
	map<int,ll> MM = enumdigsum(M);
	map<int,ll> DD = enumdigsum(D);
	
	ll ret=0;
	ITR(it,MM) if(it->first) ret += it->second*DD[it->first]%mo;
	cout<<ret%mo<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0