No.159 The USB That Won't Go In
レベル :
/ AI推定難易度 : 500
/ 実行時間制限 : 1ケース 1.000秒 / メモリ制限
: 64 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 469
作問者 :
ぴろず
タグ : / 解いたユーザー数 469
作問者 :
ぴろず
問題文最終更新日: 2026-06-26 10:14:07
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 89
(順位表)
の他の問題:
Problem Statement
It is sometimes said of USB (connectors) that "it goes in after flipping it over 2 times."
When Taro plugs in a USB, he follows the procedure below.
- Initially, the USB is face up with probability $p$ and face down with probability $(1-p)$.
- He tries to plug in the USB. When the USB is face up, it goes in with probability $q$ and does not go in with probability $(1-q)$. When the USB is face down, it does not go in.
- If the USB did not go in, he flips it over, from face up to face down or from face down to face up, and returns to step 2. If the USB went in, the procedure ends.
Let $P_i$ denote the probability that the procedure ends after flipping the USB exactly $i$ times. Taro is curious about when $P_1 < P_2$ holds.
Given $p,q$, write a program that outputs $YES$ if $P_1 < P_2$, and $NO$ otherwise.
Input
p q
$p,q$ are given on $1$ line, separated by a space. Each of $p,q$ is given to the 5th decimal place.
There is a newline at the end.
$0 \leq p \leq 1$
$0.1 \leq q \leq 1$
$|P_1 - P_2| \geq 10^{-5}$
Output
Output $YES$ or $NO$. Print a newline at the end.
Sample
Sample 1
Input
0.80000 0.50000
Output
YES
In this case, $P_1 = 0.1$ and $P_2 = 0.2$.
Sample 2
Input
0.60000 0.50000
Output
NO
In this case, $P_1 = 0.2$ and $P_2 = 0.15$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。