Find The Point
All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Jem is going to buy a house in Bearland. Can you help him to choose it?
Bearland has shape of circle with radius R metres and center at the point (0, 0). There is a house at every point with integer coordinates (expressed in metres), excluding the border. Since Jem likes traveling abroad, he wants to live very close to the border. More precisely, his house must be at most K centimeters away from the circular border. He also requires that the coordinates of his house must be positive. Find and print coordinates of any house fulfilling Jem's wishes. If there is no such house, print -1.
The first line of the input contains one integer T — the number of test cases.
The i-th of following T lines contains two integers Ri and Ki, describing one test case.
For each test case print the answer in a separate line — two integer coordinates of any house Jem can buy, or print -1 if none house satisfies the described conditions.
- 1 ≤ T ≤ 100
- 2 ≤ Ri ≤ 109
- 1 ≤ Ki ≤ 99
Input 1: 2 10 16 12 1 Output 1: 9 4 -1
test #1: Jem's house must be at most 16 centimeters - which is equal to 0.16 metres away from the border. The distance from the point (9, 4) to the border is: 10 - sqrt(92 + 42) ~ 0.15 < 0.16.
|Tags||cook74, geometry, math, medium, tuananh93|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, 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.