Chef and Two Fans
All submissions for this problem are available.
Chef is studying Rotational Motion in physics. Here is preparing for Engineering Entrance exam. He's stuck in a problem. Which states that "Two fans, each with a single blade are rotating one above the other, about the same axis of rotation and both blades have the same length. Consider the blade as a rod. Both the fans are rotating indefinitely.
Fans can rotate in either clockwise or anticlockwise direction. There is a dot marked on the blade of both the fans and the dot is marked at the same distance from the center of rotation.
You're be given speeds of the fans.
Help Chef to find the number of distinct points the dots will coincide on the circumference of rotation.
First line consists of T Test cases.
Each of the next T lines consists of Two numbers S1 and S2 which describes the speed of rotation of both the fans respectively
Print T lines with each containing the required answer.
Input: 3 1 2 6 5 1 -2 Output: 1 1 3
|Time Limit:||0.4 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.