結果

問題 No.1407 Kindness
ユーザー SSRSSSRS
提出日時 2021-12-17 03:15:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 1,556 ms
コンパイル使用メモリ 169,532 KB
実行使用メモリ 8,868 KB
最終ジャッジ日時 2023-10-12 03:42:43
合計ジャッジ時間 4,045 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,356 KB
testcase_11 AC 1 ms
4,356 KB
testcase_12 AC 19 ms
8,052 KB
testcase_13 AC 5 ms
4,348 KB
testcase_14 AC 6 ms
4,372 KB
testcase_15 AC 18 ms
7,584 KB
testcase_16 AC 11 ms
5,964 KB
testcase_17 AC 8 ms
5,012 KB
testcase_18 AC 7 ms
4,908 KB
testcase_19 AC 16 ms
7,016 KB
testcase_20 AC 13 ms
6,488 KB
testcase_21 AC 3 ms
4,352 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 13 ms
6,208 KB
testcase_24 AC 21 ms
8,608 KB
testcase_25 AC 8 ms
4,944 KB
testcase_26 AC 10 ms
5,692 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 18 ms
7,580 KB
testcase_29 AC 2 ms
4,356 KB
testcase_30 AC 19 ms
8,072 KB
testcase_31 AC 6 ms
4,348 KB
testcase_32 AC 18 ms
7,340 KB
testcase_33 AC 6 ms
4,712 KB
testcase_34 AC 13 ms
6,288 KB
testcase_35 AC 6 ms
4,592 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 19 ms
8,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main(){
  string N;
  cin >> N;
  int L = N.size();
  vector<vector<long long>> dp(L + 1, vector<long long>(2, 0));
  dp[0][0] = 1;
  for (int i = 1; i < L; i++){
    dp[i][1] = 1;
  }
  for (int i = 0; i < L; i++){
    for (int j = 0; j < 2; j++){
      for (int k = 0; k < 10; k++){
        if (!(j == 0 && k > N[i] - '0')){
          int j2 = j;
          if (k < N[i] - '0'){
            j2 = 1;
          }
          dp[i + 1][j2] += dp[i][j] * k;
          dp[i + 1][j2] %= MOD;
        }
      }
    }
  }
  cout << (dp[L][0] + dp[L][1]) % MOD << endl;
}
0