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
zemotacqy: 2017-09-10 15:15:13

AC in one go!! Elated......
Good question, use gcd ;)

asdadqwerty: 2017-09-09 21:50:31

No editorials on SPOJ?

=(Francky)=> We keep an eye. Always.

Last edit: 2017-09-10 08:25:01
asdadqwerty: 2017-09-09 21:50:01

Can someone please help me with the logic?
I tried using binary search. didnt work

testing java: 2017-09-09 17:04:14

Input is wrong. I changed my program to version in which: if there is no new value in the input stream, i keep old value in variables a,b,n. Got AC.

shubham_001: 2017-09-09 16:31:32

Test cases are correct! but this problem is copied directly :| ,plz make something by atleast some modifications :)

testing java: 2017-09-09 15:57:41

My guess is that the actual number of tests is smaller than given t. If my reader does not blow up in such case, I have WA (as I'm printing nothing or some rubbish), otherwise i have NZEC. It may be the case that my program is faulty (hence WA), however I think, that there may be something wrong with the input (as change in handling cases which should not happen, change status of my submission).

wisfaq: 2017-09-09 15:19:48

I'm getting runtime error. (both in Python and in FPC)
If I test for a=0 or b=0 or n=0 and if so output 0 then I get wrong answer.
Clearly there is something wrong with the input file(s).

[Rampage] Blue.Mary: 2017-09-09 12:07:20

Agree with @devilwolverine. The test cases are either wrong or not satisfying the input constraints.

@BlueMary: Fixed

Last edit: 2017-09-09 12:13:02
Vipul Srivastava: 2017-09-09 11:42:50

are the test cases correct?

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