結果

問題 No.189 SUPER HAPPY DAY
ユーザー snukesnuke
提出日時 2015-04-22 00:42:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 2,538 bytes
コンパイル時間 1,977 ms
コンパイル使用メモリ 83,552 KB
実行使用メモリ 16,668 KB
最終ジャッジ日時 2023-09-18 05:29:02
合計ジャッジ時間 2,158 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
16,444 KB
testcase_01 AC 12 ms
16,520 KB
testcase_02 AC 11 ms
16,532 KB
testcase_03 AC 12 ms
16,456 KB
testcase_04 AC 12 ms
16,472 KB
testcase_05 AC 13 ms
16,524 KB
testcase_06 AC 12 ms
16,668 KB
testcase_07 AC 13 ms
16,468 KB
testcase_08 AC 12 ms
16,464 KB
testcase_09 AC 12 ms
16,452 KB
testcase_10 AC 12 ms
16,524 KB
testcase_11 AC 12 ms
16,476 KB
testcase_12 AC 12 ms
16,668 KB
testcase_13 AC 20 ms
16,528 KB
testcase_14 AC 22 ms
16,464 KB
testcase_15 AC 20 ms
16,520 KB
testcase_16 AC 21 ms
16,524 KB
testcase_17 AC 22 ms
16,524 KB
testcase_18 AC 20 ms
16,668 KB
testcase_19 AC 24 ms
16,516 KB
testcase_20 AC 16 ms
16,524 KB
testcase_21 AC 17 ms
16,468 KB
testcase_22 AC 13 ms
16,604 KB
testcase_23 AC 19 ms
16,456 KB
testcase_24 AC 19 ms
16,452 KB
testcase_25 AC 26 ms
16,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cctype>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rrep(i,n) for(int i = 1; i <= n; ++i)
#define drep(i,n) for(int i = n-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vector<int> a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}

const int MX = 2015, INF = 1000010000;
const ll LINF = 1000000000000000000ll;
const double eps = 1e-10;
const int di[] = {-1,0,1,0}, dj[] = {0,-1,0,1}; //^<v>

// Mod int
const int mod = 1000000009;
struct mint{
	ll x;
	mint():x(0){}
	mint(ll x):x((x%mod+mod)%mod){}
	mint operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
	mint operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
	mint operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
	mint operator+(const mint& a)const{ return mint(*this) += a;}
	mint operator-(const mint& a)const{ return mint(*this) -= a;}
	mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
typedef vector<mint> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
//

struct dat {
  vvvi dp;
  dat(string s) {
    dp = vvvi(205,vvi(2,vi(2035)));
    int n = sz(s);
    dp[0][0][0] = 1;
    rep(i,n) {
      rep(j,MX) {
        rep(k,10) {
          dp[i+1][1][j+k] += dp[i][1][j];
        }
        rep(k,10) {
          if (s[i]-'0' > k) {
            dp[i+1][1][j+k] += dp[i][0][j];
          } else if (s[i]-'0' == k) {
            dp[i+1][0][j+k] += dp[i][0][j];
          }
        }
      }
    }
    rep(i,MX) dp[0][0][i] = dp[n][0][i]+dp[n][1][i];
  }
};

int main(){
  string s, t;
  cin >> s >> t;
  dat a(s), b(t);
  mint ans = 0;
  rrep(i,MX-1) ans += a.dp[0][0][i]*b.dp[0][0][i];
  cout << ans.x << endl;
  return 0;
}




0