結果
| 問題 | No.425 ジャンケンの必勝法 |
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-20 01:33:47 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1,004 ms / 2,000 ms |
| + 117µs | |
| コード長 | 617 bytes |
| 記録 | |
| コンパイル時間 | 54 ms |
| コンパイル使用メモリ | 14,976 KB |
| 実行使用メモリ | 33,920 KB |
| 最終ジャッジ日時 | 2026-10-03 05:42:24 |
| 合計ジャッジ時間 | 16,677 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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