The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 406 Weeks Ago, 2 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
On the planet curvy everything is curved. Even light travel in a curve there. They imported a rectangular grid and some very delicious square donuts from nearby planet straighty. The size of grid is m x n and area of a donut is one unit square.
Donuts are placed such that :
For every value of x from 0 to m, a series is created which determines the position of y coordinate on which donut is placed :
Yn = Yn-1 + n
where ,
Yn = y coordinate of current donut.
Yn-1 = y-coordinate of previous donut.
n = number of donut for current series.
Y1 is equal to the x coordinate for that particular series.
for eg x=1 donuts are placed at
Y=1, Y=3, Y=6, Y=10 , …..
For x=2 donuts are placed at:
Y=2, Y=4, Y=7….
Equation of curve of line of sight at position (0,0) is given by:
Y=(x-a)^2
On the day of competition contestant are asked to stand at a position (0,b). Now you have to determine how many donuts does that contestant can see.
Note that since area of donut is 1 unit square, if a donut is placed at (h,k) then is visible from
(x,y) such that : ( ( h - 0.5 )
The first line of the input contains an integer T denoting the number of test cases, each test case contains size of grid (MxN) i.e value of M & N followed by values of a & b.
For each test case, output a single line with number of donuts visible to person.
Input: 2 10 10 1 2 25 50 2 5 Output: 5 14
Â
Case 1 : for grid 10x10 and person standing at (0,2) , donuts visible to him are at coordinates
(1,1) , (2,2) , (3,3), (3,5) , (4,9)
Case 2 : for grid 25x50 and person standing at (0,5) , donuts visible to him are at coordinates
(1,1) , (1,3), (3,3), (4,4), (4,6), (5,7), (5,10),
(6,15), (6,20), (7,21), (7,27), (8,35), (8,43), (9,44)
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll