結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー SSRSSSRS
提出日時 2021-03-05 21:31:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 453 ms / 3,000 ms
コード長 1,107 bytes
コンパイル時間 1,884 ms
コンパイル使用メモリ 172,684 KB
実行使用メモリ 152,300 KB
最終ジャッジ日時 2024-04-16 08:50:52
合計ジャッジ時間 5,534 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 6 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 6 ms
5,376 KB
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 6 ms
5,376 KB
testcase_26 AC 6 ms
5,376 KB
testcase_27 AC 6 ms
5,376 KB
testcase_28 AC 6 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 36 ms
15,104 KB
testcase_31 AC 40 ms
18,560 KB
testcase_32 AC 86 ms
33,280 KB
testcase_33 AC 228 ms
77,696 KB
testcase_34 AC 407 ms
148,724 KB
testcase_35 AC 419 ms
152,280 KB
testcase_36 AC 417 ms
152,172 KB
testcase_37 AC 453 ms
152,300 KB
testcase_38 AC 380 ms
152,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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