#Lutece1297. Bank
Bank
Migrated from Lutece 1297 Bank
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Given CNY (Chinese yuan)
, can you exchange it to exactly CNY
soon? The only way you have is to spend money at a vending machine once, which has an infinite number of copies of merchandise of all possible positive price.
However, you cannot make any assumptions about the way the vending machine will make change; it is only guaranteed that it will dispense banknotes/coins that sum to the amount of change required.
What’s the smallest total amount you have to spend in all case, to get a banknote/coin of CNY
?
Only fen
(CNY
), fen
, fen
, jiao
(CNY
), jiao
, jiao
, yuan
(CNY
), yuan
, yuan
, yuan
, yuan
, yuan
and yuan
the vending machine will accept or return.
Input
The first line contains an integer , denoting the number of the test cases.
;
Each test case contains two number and .
and .
Output
For each test case, output a number denoting the answer.
Samples
Note
只要找给你的钱能凑出Y就行
小数点后不要输出多余的位数,比如0.2不要输出0.20
对于任意X,假如你的答案是Z 那么对于X-Z的任意一种组合,都要能凑出Y
The sample input: If you spend 0.01,you may get 0.02 and 0.02,and can't get 0.01 anymore.
The answer is 0.02,in this case, you can get 0.01,0.01,0,01 or 0.01 0.02.
You can get 0.01 anyway.
Resources
The 14th UESTC Programming Contest Preliminary