結果
| 問題 | No.189 SUPER HAPPY DAY | 
| コンテスト | |
| ユーザー |  nenuon | 
| 提出日時 | 2017-08-02 23:16:43 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,399 bytes | 
| コンパイル時間 | 808 ms | 
| コンパイル使用メモリ | 90,804 KB | 
| 実行使用メモリ | 14,864 KB | 
| 最終ジャッジ日時 | 2024-10-11 06:01:17 | 
| 合計ジャッジ時間 | 2,352 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 RE * 2 | 
ソースコード
#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;
}
            
            
            
        