No.338 Survey Feature
タグ : / 解いたユーザー数 276
作問者 :
buko106
Problem Statement
A certain site used its survey feature to conduct a two-choice "Yes" or "No" survey. There was at least one response, and as a result, $A$% of people answered "Yes" and $B$% answered "No".
Here, $A,B$ are values rounded to the nearest integer (fractional part rounded half up). That is, if $a$ people voted "Yes" and $b$ people voted "No", then $A,B$ are the values of $\displaystyle \frac{100a}{a+b},\frac{100b}{a+b}$ rounded to the nearest integer (fractional part rounded half up).
Given integers $A$ and $B$, among the pairs $(a,b)$ for which this result holds, find one that minimizes the total number of respondents $a+b$ (where $a+b \geq 1$).
Input
A B
$0 \leq A \leq 100$
$0 \leq B \leq 100$
It is guaranteed that there exists a pair $(a,b)$ for which the result is $A$%, $B$%.
Output
Output the minimum value of $a+b$ satisfying the conditions on one line. Print a newline at the end.
Sample
Sample 1
Input
50 50
Output
2
When a=b=1, a+b is minimized.
Sample 2
Input
1 99
Output
67
This is the case a=1,b=66.
Sample 3
Input
3 98
Output
40
When a=1,b=39, we have 100a/(a+b)=2.5,100b/(a+b)=97.5, so a pair (a,b) satisfying the input does indeed exist.
Note that A+B=100 does not necessarily hold.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。