結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー marroncastlemarroncastle
提出日時 2021-03-15 12:03:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 248 ms / 3,000 ms
コード長 1,256 bytes
コンパイル時間 386 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 78,348 KB
最終ジャッジ日時 2024-04-24 16:03:43
合計ジャッジ時間 5,811 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,736 KB
testcase_01 AC 43 ms
53,120 KB
testcase_02 AC 102 ms
76,416 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 42 ms
52,608 KB
testcase_05 AC 42 ms
52,608 KB
testcase_06 AC 43 ms
52,608 KB
testcase_07 AC 42 ms
52,608 KB
testcase_08 AC 42 ms
52,992 KB
testcase_09 AC 43 ms
52,608 KB
testcase_10 AC 43 ms
52,736 KB
testcase_11 AC 43 ms
52,608 KB
testcase_12 AC 59 ms
63,360 KB
testcase_13 AC 62 ms
64,384 KB
testcase_14 AC 72 ms
68,480 KB
testcase_15 AC 88 ms
74,496 KB
testcase_16 AC 100 ms
76,672 KB
testcase_17 AC 100 ms
76,416 KB
testcase_18 AC 112 ms
76,344 KB
testcase_19 AC 106 ms
76,288 KB
testcase_20 AC 115 ms
76,472 KB
testcase_21 AC 110 ms
76,416 KB
testcase_22 AC 116 ms
76,484 KB
testcase_23 AC 114 ms
76,416 KB
testcase_24 AC 100 ms
76,288 KB
testcase_25 AC 115 ms
76,544 KB
testcase_26 AC 111 ms
76,416 KB
testcase_27 AC 114 ms
76,356 KB
testcase_28 AC 113 ms
76,476 KB
testcase_29 AC 118 ms
76,464 KB
testcase_30 AC 157 ms
77,444 KB
testcase_31 AC 125 ms
77,376 KB
testcase_32 AC 175 ms
78,032 KB
testcase_33 AC 190 ms
77,888 KB
testcase_34 AC 239 ms
78,020 KB
testcase_35 AC 240 ms
78,216 KB
testcase_36 AC 243 ms
78,348 KB
testcase_37 AC 248 ms
78,152 KB
testcase_38 AC 184 ms
76,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = list(map(int,list(input())))
digit = len(N)
MOD = 10**9+7
twos = [0,0,1,0,2,0,1,0,3,0]
fives = [0,0,0,0,0,1,0,0,0,0]
dp = [[[0]*3 for _ in range(3)] for _ in range(2)]
dp[1][0][0] = 1
for i in range(digit):
  new_dp = [[[0]*3 for _ in range(3)] for _ in range(2)]
  if N[i]>0:
    for two in range(3):
      for five in range(3):
        new_dp[1][min(2,two+twos[N[i]])][min(2,five+fives[N[i]])] += dp[1][two][five]
        new_dp[1][two][five] %= MOD
    for k in range(1,N[i]):
      for two in range(3):
        for five in range(3):
          new_dp[0][min(2,two+twos[k])][min(2,five+fives[k])] += dp[1][two][five]
          new_dp[0][two][five] %= MOD
  for k in range(1,10):
    for two in range(3):
      for five in range(3):
        new_dp[0][min(2,two+twos[k])][min(2,five+fives[k])] += dp[0][two][five]
        new_dp[0][two][five] %= MOD
  dp = new_dp
ans = dp[0][2][2] + dp[1][2][2]

dp2 = [[0]*3 for _ in range(3)]
dp2[0][0] = 1
for i in range(digit-1):
  new_dp2 = [[0]*3 for _ in range(3)]
  for k in range(1,10):
    for two in range(3):
      for five in range(3):
        new_dp2[min(2,two+twos[k])][min(2,five+fives[k])] += dp2[two][five]
        new_dp2[two][five] %= MOD
  dp2 = new_dp2
  ans += dp2[2][2]
  ans %= MOD
print(ans)
0