THREENUMBERS - nth number

no tags 

Given two numbers a and b, you have to find n-th number which is divisible by a or b.


First line contains an integer T (<= 100000), denoting number of test cases.

Second line contains 3 positive integers a, b and n. (a, b <= 10000, n <= 1000000000)


Print n-th number in a new line.


2 3 10

hide comments
nadstratosfer: 2018-06-12 21:36:54

Kudos to wisfaq for figuring out that the missing testcase requires reprinting the last result. Completely lame from psetter to leave something like this for solvers to handle. -1

sonuverma: 2018-01-08 06:31:21

Binary Search :-)

Nishant Gupta: 2017-12-24 21:04:44

Some input files seem to be broken which will cause Fast I/O yielding TLE.
Use scanf for input.

holmesherlock: 2017-11-05 19:39:58

very good problem :-)

mahilewets: 2017-09-16 17:05:14

Nice, I learned how to handle exceptions in Python

Aleksandar Kostadinov: 2017-09-11 21:46:55

@wisfaq: Thanks for usefull hint!

wisfaq: 2017-09-11 20:44:38

@David (and others having problems with NZEC)
One of the ways to overcome those problems is to use error handling.
Something like:
__read a,b,n
__get answer(a,b,n)
__store answer
__print answer
_print stored (previous) answer.
That's the way I got AC with Python

Last edit: 2017-09-11 20:48:39
David N. Springer: 2017-09-11 15:30:37

If I check for premature EOF, I get WA otherwise I get NZEC.
Please help. How to handle missing testcase?

vengatesh15: 2017-09-11 08:27:26

easy one ..

kkgujjar: 2017-09-10 20:01:59

can anyone send me the hint or solution of this problem ??

Added by:surayans tiwari
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)