Submit | All submissions | Best solutions | Back to list |
SPEED - Circular Track |
Two persons are running on a circular track either in the same direction or in the opposite direction, indefinitely. The speed of both of them is given to you. Speed will be positive in clockwise direction, and negative in anticlockwise direction. Print the number of distinct points, at which they will meet on the circle.
Input
First line contains T, number of test cases. Each test case contains two integers, S1 and S2 (not equal to zero) which are the speeds of the two persons. S1 and S2 will be distinct.
Edited: All the numbers fit in signed 32-bit integer.
Output
Print in a separate line, the number of distinct points at which they meet.
Example
Input 2 1 2 1 -1 Output 1 2
Added by: | Nikunj Jain |
Date: | 2011-07-21 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM32-GCC MAWK BC BF C-CLANG NCSHARP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GRV JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PICO PROLOG PYPY3 R RACKET RUST SCM qobi CHICKEN SQLITE SWIFT UNLAMBDA VB.NET |
hide comments
2014-12-27 00:08:36 Cameron Blocker
I just read them in as ints and it worked fine. |
|
2014-12-22 06:04:39 Andrew Huff
What values can S1 and S2 take? Are they always integers? How large/small will they be? |
|
2014-12-13 23:23:43 nondescript
Last edit: 2014-12-24 16:58:25 |