結果
問題 | No.162 8020運動 |
ユーザー |
![]() |
提出日時 | 2020-04-09 00:41:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 35 ms / 5,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 103 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-07-19 05:57:29 |
合計ジャッジ時間 | 2,105 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from functools import lru_cache A, *P = map(int, read().split()) P = tuple(x / 100 for x in P) @lru_cache(None) def f(N, i, rest_year, left_flag=False): """ N 本の歯があり、i-1番の歯まで虫判定を終えた""" if N == 0: return 0 if rest_year == 0: return N if i == N: return f(N, 0, rest_year - 1) p = P[0] if N == 1 else P[1] if i in (0, N - 1) else P[2] if i == 0 and left_flag: p = P[1] if i == N-1 else P[2] # 抜く場合 x = f(i, 0, rest_year - 1) + f(N - i - 1, 0, rest_year, True) # 抜かない場合 y = f(N, i + 1, rest_year) return p * x + (1 - p) * y answer = f(14, 0, 80 - A) * 2 print(answer)