結果

問題 No.189 SUPER HAPPY DAY
ユーザー 👑 kmjpkmjp
提出日時 2015-04-22 00:30:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 1,413 bytes
コンパイル時間 1,762 ms
コンパイル使用メモリ 155,860 KB
実行使用メモリ 7,044 KB
最終ジャッジ日時 2023-09-18 04:06:08
合計ジャッジ時間 4,568 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
6,568 KB
testcase_01 AC 46 ms
6,672 KB
testcase_02 AC 47 ms
6,796 KB
testcase_03 AC 47 ms
6,648 KB
testcase_04 AC 47 ms
6,624 KB
testcase_05 AC 45 ms
6,648 KB
testcase_06 AC 46 ms
6,696 KB
testcase_07 AC 46 ms
6,668 KB
testcase_08 AC 46 ms
6,732 KB
testcase_09 AC 45 ms
6,568 KB
testcase_10 AC 47 ms
6,596 KB
testcase_11 AC 46 ms
6,824 KB
testcase_12 AC 47 ms
6,572 KB
testcase_13 AC 69 ms
6,676 KB
testcase_14 AC 82 ms
6,712 KB
testcase_15 AC 89 ms
6,776 KB
testcase_16 AC 96 ms
6,688 KB
testcase_17 AC 96 ms
6,784 KB
testcase_18 AC 83 ms
6,864 KB
testcase_19 AC 101 ms
7,044 KB
testcase_20 AC 59 ms
6,704 KB
testcase_21 AC 59 ms
6,688 KB
testcase_22 AC 47 ms
6,676 KB
testcase_23 AC 46 ms
6,692 KB
testcase_24 AC 47 ms
6,788 KB
testcase_25 AC 47 ms
6,864 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> MM,DD;
ll dp[205][2050];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	dp[0][0]=1;
	FOR(i,202) {
		for(y=2000;y>=0;y--) {
			for(x=9;x>=0;x--) (dp[i+1][y+x]+=dp[i][y])%=mo;
		}
	}
	
	cin>>M>>D;
	
	reverse(M.begin(),M.end());
	reverse(D.begin(),D.end());
	int tot=0;
	while(D.size()) {
		int x=D[D.size()-1]-'0';
		FOR(i,x) FOR(y,2020) if(dp[D.size()-1][y]) (DD[y+tot+i] += dp[D.size()-1][y])%=mo;
		tot+=x;
		D.pop_back();
	}
	DD[tot]++;
	
	tot=0;
	while(M.size()) {
		int x=M[M.size()-1]-'0';
		FOR(i,x) FOR(y,2020) if(dp[M.size()-1][y]) (MM[y+tot+i] += dp[M.size()-1][y])%=mo;
		tot+=x;
		M.pop_back();
	}
	MM[tot]++;
	
	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