結果
問題 | No.1106 🦉 何事もバランスが大事 |
ユーザー | tamato |
提出日時 | 2020-07-03 22:35:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 1,500 bytes |
コンパイル時間 | 1,014 ms |
コンパイル使用メモリ | 81,900 KB |
実行使用メモリ | 72,360 KB |
最終ジャッジ日時 | 2024-09-17 04:17:09 |
合計ジャッジ時間 | 7,412 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,332 KB |
testcase_01 | AC | 39 ms
53,692 KB |
testcase_02 | AC | 40 ms
54,428 KB |
testcase_03 | AC | 39 ms
53,612 KB |
testcase_04 | AC | 66 ms
69,752 KB |
testcase_05 | AC | 40 ms
53,544 KB |
testcase_06 | AC | 39 ms
53,564 KB |
testcase_07 | AC | 39 ms
52,900 KB |
testcase_08 | AC | 40 ms
54,280 KB |
testcase_09 | AC | 40 ms
53,008 KB |
testcase_10 | AC | 40 ms
54,196 KB |
testcase_11 | AC | 39 ms
53,196 KB |
testcase_12 | AC | 49 ms
62,976 KB |
testcase_13 | AC | 53 ms
64,036 KB |
testcase_14 | AC | 56 ms
66,660 KB |
testcase_15 | AC | 60 ms
68,044 KB |
testcase_16 | AC | 60 ms
67,216 KB |
testcase_17 | AC | 59 ms
66,956 KB |
testcase_18 | AC | 60 ms
67,408 KB |
testcase_19 | AC | 61 ms
67,472 KB |
testcase_20 | AC | 63 ms
67,828 KB |
testcase_21 | AC | 64 ms
69,380 KB |
testcase_22 | AC | 65 ms
70,192 KB |
testcase_23 | AC | 66 ms
69,600 KB |
testcase_24 | AC | 67 ms
71,952 KB |
testcase_25 | AC | 64 ms
69,456 KB |
testcase_26 | AC | 67 ms
71,320 KB |
testcase_27 | AC | 66 ms
69,820 KB |
testcase_28 | AC | 68 ms
71,256 KB |
testcase_29 | AC | 67 ms
70,728 KB |
testcase_30 | AC | 66 ms
69,872 KB |
testcase_31 | AC | 68 ms
71,148 KB |
testcase_32 | AC | 66 ms
69,912 KB |
testcase_33 | AC | 65 ms
69,900 KB |
testcase_34 | AC | 65 ms
70,332 KB |
testcase_35 | AC | 65 ms
69,240 KB |
testcase_36 | AC | 67 ms
71,032 KB |
testcase_37 | AC | 65 ms
69,436 KB |
testcase_38 | AC | 64 ms
69,600 KB |
testcase_39 | AC | 67 ms
72,360 KB |
testcase_40 | AC | 67 ms
72,276 KB |
testcase_41 | AC | 64 ms
70,388 KB |
testcase_42 | AC | 66 ms
70,444 KB |
testcase_43 | AC | 65 ms
69,992 KB |
testcase_44 | AC | 66 ms
71,976 KB |
testcase_45 | AC | 66 ms
71,444 KB |
testcase_46 | AC | 67 ms
69,504 KB |
testcase_47 | AC | 68 ms
71,248 KB |
testcase_48 | AC | 65 ms
69,980 KB |
testcase_49 | AC | 66 ms
70,280 KB |
testcase_50 | AC | 64 ms
70,040 KB |
testcase_51 | AC | 59 ms
66,628 KB |
testcase_52 | AC | 67 ms
71,544 KB |
testcase_53 | AC | 68 ms
72,092 KB |
testcase_54 | AC | 67 ms
70,312 KB |
testcase_55 | AC | 65 ms
69,572 KB |
testcase_56 | AC | 65 ms
69,932 KB |
testcase_57 | AC | 65 ms
70,896 KB |
testcase_58 | AC | 65 ms
70,208 KB |
testcase_59 | AC | 65 ms
70,404 KB |
testcase_60 | AC | 66 ms
70,192 KB |
testcase_61 | AC | 66 ms
70,364 KB |
testcase_62 | AC | 67 ms
71,200 KB |
testcase_63 | AC | 69 ms
70,976 KB |
testcase_64 | AC | 65 ms
70,672 KB |
testcase_65 | AC | 61 ms
68,492 KB |
testcase_66 | AC | 66 ms
70,788 KB |
testcase_67 | AC | 69 ms
71,308 KB |
testcase_68 | AC | 65 ms
71,416 KB |
testcase_69 | AC | 66 ms
71,624 KB |
testcase_70 | AC | 66 ms
71,432 KB |
testcase_71 | AC | 66 ms
71,040 KB |
testcase_72 | AC | 67 ms
71,472 KB |
testcase_73 | AC | 66 ms
72,156 KB |
testcase_74 | AC | 64 ms
70,164 KB |
testcase_75 | AC | 65 ms
71,236 KB |
testcase_76 | AC | 64 ms
69,432 KB |
testcase_77 | AC | 64 ms
69,600 KB |
testcase_78 | AC | 65 ms
70,544 KB |
testcase_79 | AC | 65 ms
69,740 KB |
testcase_80 | AC | 65 ms
69,740 KB |
testcase_81 | AC | 65 ms
70,248 KB |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) F = [] while N: n, m = divmod(N, 5) if m < 3: F.append(m) N = n else: F.append(m-5) N = n+1 F.reverse() L = len(F) dp0 = [[0] * (4*L+1) for _ in range(L+1)] dp1 = [[0] * (4*L+1) for _ in range(L+1)] dp0[0][0] = 1 for i in range(L): f = F[i] for j in range(-2*L, 2*L+1): for b in range(-2, 3): if b < f: dp1[i+1][j+b] += dp0[i][j] + dp1[i][j] elif b > f: dp1[i+1][j+b] += dp1[i][j] else: dp0[i+1][j+b] += dp0[i][j] dp1[i+1][j+b] += dp1[i][j] ans = dp0[-1][0] + dp1[-1][0] dp0 = [[0] * (4 * L + 1) for _ in range(L + 1)] dp1 = [[0] * (4 * L + 1) for _ in range(L + 1)] dp0[0][0] = 1 F = [0] * L for i in range(L): f = F[i] for j in range(-2 * L, 2 * L + 1): for b in range(-2, 3): if b < f: dp1[i + 1][j + b] += dp0[i][j] + dp1[i][j] elif b > f: dp1[i + 1][j + b] += dp1[i][j] else: dp0[i + 1][j + b] += dp0[i][j] dp1[i + 1][j + b] += dp1[i][j] ans_neg = dp0[-1][0] + dp1[-1][0] print(ans - ans_neg) if __name__ == '__main__': main()