Balance the see-saw
All submissions for this problem are available.
Ajay and his brother went to a garden. They found a see-saw there of huge length. He and his brother wanted to play a game where they will sit on the opposite sides and they wanted the see-saw to be balanced. We know the weights of Ajay and his brother. Now print all the points where he and his brother can sit. The see-saw is of even length (end to end) and the points at which they will sit is measured from the centre of the see-saw. For simplicity assume that Ajay always sits on the left side and his brother on right side.
First line will contain n (end to end length of the see-saw, even length), Ajay's weight and his brother's weight. It's guaranteed that all the distances will be integers.
Print in new lines, the distances in increasing order from centre to the position where Ajay and his brother can sit respectively.
- 2 ≤ n ≤ 5*105
- 1 ≤ w1 , w2 ≤ 500
Input: 10 3 6 Output: 2 1 4 2
|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
If you are still having problems, see a sample solution here.