LCC '23 Contest 4 S1 - Common Interests
View as PDF is trying to come up with a pickup line for his valentine, but is having trouble deciding on what to talk about! He could be generic, but there's no way that works, and he could talk about the little things, but then it might seem like he's too interested! Thus, tells him to write down the first things that come to mind that he could talk about.
While there may be no way to model 's brain in code, let's denote the integer as everything is interested in, and the integer
as everything his valentine is interested in. Factors of both
and
represent things that both and his valentine are interested in. The
things that wrote down can be represented as the
largest of these factors (the more generic, the higher the corresponding number).
Adhering to 's advice, can you find the largest numbers that divide both
and
?
Constraints
Subtask 1 [40%]
Subtask 2 [60%]
Input Specification
The first and only line of input contains ,
, and
.
Output Specification
Output on a single line the largest numbers that divide both
and
, ordered from least to greatest. If there are less than
factors that divide
and
, output all the factors, again from least to greatest.
Sample Input 1
24 18 4
Sample Output 1
1 2 3 6
Sample Input 2
25 100 5
Sample Output 2
1 5 25
Comments