Free Candies For Everyone!
All submissions for this problem are available.There is a special offer in Ankur’s local grocery store: if the customer buys $a$ candies, he or she may take $b$ additional candies for free. This special offer can be used infinite number of times. Ankur currently has $s$ rupees, and he wants to get as many candies for free. Each candy costs $c$ rupees. Help Ankur to calculate the maximum possible number of candies he can get!
InputThe first line contains one integer $t( 1 \leq t \leq 100)$ — the number of testcases. Each of the next t lines contains four integers $s,a,b,c (1 \leq s,a,b,c \leq 10^9)$ — the number of rupees Ankur has, the number of candies he has to buy to use the special offer, the number of candies he will get for free, and the cost of one candy, respectively.
OutputPrint $t$ lines. $i$-th line should contain the maximum possible number of candies Ankur can get in $i$-th test.
14 4 1 2
27 5 3 2
11 2 1 1
|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, rust, SCALA, swift, 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, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.