P27115 [AtCoder] Beterminant
普及+
题目描述

Problem Description

In a single bet, "the amount of money you have decreases by 1 yen. With a probability of \( P \)%, the amount of money increases by \( W \) yen (win), and with a probability of \( (100 - P) \)%, you get nothing (lose)." Note that the amount of money can be any integer value.

Find the largest positive integer \( n \) that satisfies the following condition. If no such \( n \) exists, answer \( -1 \). If there are infinitely many such \( n \), answer \( -2 \).

Condition. Initially, the whale has 0 yen. The whale makes \( n \) bets (the probabilities in each bet are independent). At this time, the probability that the whale's final amount of money is strictly more than 0 yen is strictly greater than \( \frac{1}{2} \).

Input Format

The input is given from the standard input in the following format:

\( P \) \( W \)

Output Format

Find the largest \( n \) that satisfies the condition in the problem statement. If no such \( n \) exists, output -1. If there are infinitely many such \( n \), output -2.

Sample Input and Output

Sample Input #1

30 3

Sample Output #1

2

Sample Input #2

20 3

Sample Output #2

-1

Sample Input #3

40 3

Sample Output #3

-2

Notes/Hints

Constraints

  • \( 0 \le P \le 100 \).
  • \( 0 \le W \le 100 \).
  • \( P \) and \( W \) are integers.

Sample Explanation 1

\( n = 2 \) satisfies the condition. The probability that the whale's final amount of money is strictly more than 0 yen is \( \frac{51}{100} \), as follows:
- The probability of winning in both the first and second bets is \( \frac{9}{100} \), resulting in a final amount of 4 yen.
- The probability of winning in the first bet and losing in the second bet is \( \frac{21}{100} \), resulting in a final amount of 1 yen.
- The probability of losing in the first bet and winning in the second bet is \( \frac{21}{100} \), resulting in a final amount of 1 yen.
- The probability of losing in both the first and second bets is \( \frac{49}{100} \), resulting in a final amount of -2 yen.
On the other hand, it can be proven that \( n > 2 \) does not satisfy the condition. Therefore, the largest \( n \) is 2.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
30 3
样例输出
2