結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-20 01:33:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,580 ms / 2,000 ms |
| コード長 | 617 bytes |
| コンパイル時間 | 92 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 44,588 KB |
| 最終ジャッジ日時 | 2024-12-14 03:45:41 |
| 合計ジャッジ時間 | 24,660 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 18 |
ソースコード
#!/usr/bin/ python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
p0, q = map(int, read().split())
p0 /= 100
q /= 100
def solve(depth, p):
if depth > 20:
return 0.5
if p < 0:
p = 0
return (1 / 3) + solve(depth + 1, p + q) / 3
if p > 1:
p = 1
return (1 / 2) + solve(depth + 1, p - q) / 2
x = (1 / 3) + solve(depth + 1, p + q) / 3
y = (1 / 2) + solve(depth + 1, p - q) / 2
return x * (1 - p) + y * p
x = solve(0, p0)
answer = 1 / 3 + x / 3
print(answer)
maspy