結果

問題 No.189 SUPER HAPPY DAY
ユーザー nenuonnenuon
提出日時 2017-08-02 23:16:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,399 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 91,112 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-19 13:37:09
合計ジャッジ時間 2,021 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 25 ms
9,600 KB
testcase_14 AC 31 ms
11,264 KB
testcase_15 AC 26 ms
9,984 KB
testcase_16 AC 25 ms
10,112 KB
testcase_17 AC 30 ms
11,392 KB
testcase_18 AC 24 ms
9,728 KB
testcase_19 AC 37 ms
12,544 KB
testcase_20 AC 13 ms
7,040 KB
testcase_21 AC 17 ms
7,808 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 19 ms
9,856 KB
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
const int mod = 1e9 + 9;
ll dp1[201][2][2000]; // 桁数、小さいことが確定しているか、各桁の和
ll dp2[201][2][2000];
string M, D;
void calc1(){
  int len = M.length();
  FOR(i,0,len+1) FOR(j,0,2) FOR(k,0,2000) {
    dp1[i][j][k] = 0;
  }
  dp1[0][0][0] = 1;
  FOR(i,0,len) FOR(j,0,2) FOR(k,0,2000) {
    int lim = j ? 9 : M[i] - '0';
    FOR(d,0,lim+1) {
      if(k+d>=2000) continue;
      (dp1[i+1][j||d<lim][k+d] += dp1[i][j][k]) %= mod;
    }
  }
}
void calc2(){
  int len = D.length();
  FOR(i,0,len+1) FOR(j,0,2) FOR(k,0,2000) {
    dp2[i][j][k] = 0;
  }
  dp2[0][0][0] = 1;
  FOR(i,0,len) FOR(j,0,2) FOR(k,0,2000) {
    int lim = j ? 9 : D[i] - '0';
    FOR(d,0,lim+1) {
      if(k+d>=2000) continue;
      (dp2[i+1][j||d<lim][k+d] += dp2[i][j][k]) %= mod;
    }
  }
}
int main()
{
  cin >> M >> D;
  calc1();
  calc2();
  ll ans = 0;
  FOR(k,1,2000) {
    ans += ((dp1[M.length()][0][k]+dp1[M.length()][1][k])%mod) * ((dp2[D.length()][0][k]+dp2[D.length()][1][k])%mod);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
0