NINJA3 - STUNNING GCD

no tags 

You are given three numbers N, a, b. You can build a number X by repeating N 'a' times and the number Y by repeating N 'b' times. Now that you have the numbers X and Y, determine the GCD of the two numbers X and Y.

Input format:

The first line contains an integer T, the number of test cases.

Then for each test case, there are three integers in each line: N, a, b.

Output format:

Print the required answer for each test case in a single line.

Constraints:

1 <= T <= 100

1 <= N, a, b <= 10^18

Sample:

Input:
1
123 2 3

Output:
123

hide comments
nacly_fish: 2022-10-26 12:18:14

If input: 123456789123456789 1000000000000000000 1000000000000000000
then output will be about 16M TB

Robert Lewon: 2021-10-15 15:23:00

The issue with "missing testcases" should be fixed. Sorry for the inconvenience.

psz2007: 2021-09-24 04:33:58

The data seems to be crashed.....@mombassa can you fix it?

olive_r: 2020-05-27 08:35:15

this problem will be happy ! if printf : answer % (10^9 +7)
at moment ! that is very hard !

Last edit: 2020-05-27 08:39:01
sanyam19: 2018-01-11 17:02:57

easy 1 :)) AC in 1 go...

ayushgupta1997: 2017-12-25 18:38:50

GOod Problem observe :)

satyam_lal: 2017-12-23 18:48:09

idk why am i getting a run time error(NZEC) on python i am getting absolutely correct answers when i execute it on an IDE

shub1025: 2017-12-15 05:53:26

My 50th ..easy Ac at one go

Rafail Loizou: 2017-08-17 01:31:52

Just because the introduction is not clear: lets say you have this case: 3 4 8
You should NOT output: 12.
Instead you should output: 3333. I wanted to share this because the sample case is not explaining the way the output must be done (because if it would that would leak the answer but yet again giving this case doesn't directly leak it nor it makes it completely easy, it just makes this solvable cause otherwise u just have to guess what captain mombasa here really wanted)

namitp: 2017-07-30 16:01:22

After a long a problem in one Go.....
Easy One...


Added by:mombassa
Date:2016-02-17
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU JS-MONKEY