RK and Iron Man
All submissions for this problem are available.
RK is a huge fan of Iron Man. RK helped Tony Stark design his artificial intelligence system “J.A.R.V.I.S”. So, Tony has decided to return the favour by letting him roam around in his latest Iron Man Armor – “The Mark XLV”.
So the other day they were just hanging around in Stark Tower , eating Donuts, when Stark asked RK that how many cities did he plan to roam before coming back to the Stark Tower. Now, RK has his own cool way of answering questions. He says that he will roam a city in M line segments and after each segment , he will take a turn towards right at Theta degrees . However, at the end of one city and beginning of another city , he would take a left turn at Theta degrees. Saying that , RK takes off.
Tony is left behind wondering how many cities will RK roam around before coming back or is his latest armor gone ?
So, Stark has assigned you with this task of finding out how many cities will RK roam before coming back to Stark Tower.
Assume that, RK will never cut any previous segment and will never roam around a city that has already been roamed. However, If he faces such a situation following his “way” of roaming and has never reached stark tower yet, RK will never go back to the Stark Tower and take “The Mark XLV” with him.
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows."
- Each test case contains two space separated integers M and Theta where M represents number of segments to cover a city and Theta represents the angle by which RK will take turns.
- For each Test case, Output the number of cities RK will roam before coming back to Stark Tower . However if he will not return ,then output -1.
- 1 ≤ T ≤ 10000
- 1 ≤ M ≤ 1000
- 0 ≤ Theta ≤ 90
Input: 1 3 90 Output: 4
|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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.