# help..TWO FRIENDS AT THE ZOO

what is wrong with solution:
https://www.codechef.com/viewsolution/12835638

Dear! You are over-complicating a simple question!

Here, note this observation.

Lets say that a number n has factor f and multiple m.
Now, we can say n=kf since f is factor of n. [k is a integer]

And m is l*n , where l is another integer.

==>m= k x l x f.
==>m is divisible by f. Agree?

So all you need to do is a divisibility test!!

Check my solution [here][1]

EDIT1- I think what you are trying to do, is supposing if multiple is negative, like 3 x (-2) = -6. Have a look at constraints. It states that f and m >0. And since multiple, by definition, is an integral multiple of n, it is guaranteed that m>f. I hope this helps you dear!!
[1]: https://www.codechef.com/viewsolution/12835778

1 Like

@viral

Your code is giving time limit exceeded in cases like

factor = 2 , multiple = 10^18

Because of multiple test cases, what your program does is to subtract it till f and m become equal or something. This is making it do ALOT of unnecessary operation which lead to it exceeding time limit. Use % operator and the Q will be easily solved!!