結果

問題 No.189 SUPER HAPPY DAY
ユーザー nenuonnenuon
提出日時 2017-08-02 23:15:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,398 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 92,852 KB
実行使用メモリ 14,968 KB
最終ジャッジ日時 2024-04-19 13:37:06
合計ジャッジ時間 2,181 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 3 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 3 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 3 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
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 + 7;
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