結果
問題 | No.1417 100の倍数かつ正整数(2) |
ユーザー |
![]() |
提出日時 | 2021-02-20 03:24:39 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 955 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 82,436 KB |
実行使用メモリ | 276,152 KB |
最終ジャッジ日時 | 2024-09-25 00:22:19 |
合計ジャッジ時間 | 16,262 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 TLE * 1 -- * 8 |
ソースコード
#assertfrom itertools import productN = input()if not(1<=int(N)<=10**100):print('error')mod=10**9+7def count(a):n = len(a)dp=[[[[[0] * 2 for i in range(3)] for j in range(3)] for k in range(2)] for l in range(n+1)]dp[0][0][0][0][0] = 1for i, less, divcnt5, divcnt2, has0 in product(range(n), (0,1), range(3), range(3), (0,1)):max_d = 9 if less else int(a[i])for d in range(max_d+1):less_ = less or d < max_ddivcnt5_ = min(2,divcnt5+(d==5))if d==4 or d==8:divcnt2_=2elif d==2 or d==6:divcnt2_=min(2,divcnt2+1)else:divcnt2_ = divcnt2has0_ = has0 or d==0dp[i + 1][less_][divcnt5_][divcnt2_][has0_] += dp[i][less][divcnt5][divcnt2][has0]return dp[n][0][2][2][0]+dp[n][1][2][2][0]ans = count(N)for i in range(len(N)):ans += count('9'*i)print(ans%mod)