Chef and Bakery
Recently Chef has left his job and started his own bakery. So the people of Chefland have decided to buy food from Chef's bakery. The cost of every item at chef's bakery is same. Assuming that you are a resident of Chefland, you always want to buy maximum number of items such that after buying maximum number of items, you still have some money left with you. Initially, you have some fixed amount of money in your wallet.
First line of input contain T , number of test cases. next T lines of input contains two space separated integers N and X where N is the total initial amount of money in your wallet and X is the cost of each item.
Single line of output should print the money left in your wallet after buying maximum number of items.
Constraints and Sub-tasks
Input: 1 10 3 Output: 1
Initially you have an amount of 10 in your wallet and cost of each item is 3 ,so you can buy maximum of 3 items and still having left amount 1 in your wallet.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions