

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
長さ の数列 と 以下の正整数 が与えられます。
について次の問題を解いてください。
- を含むように 個の要素を から選ぶ時、それらの最大公約数 (GCD) としてあり得る最大値を求めてください。
制約
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
出力
行出力せよ。 行目には の時の答えを出力せよ。
入力例 1Copy
5 2 3 4 6 7 12
出力例 1Copy
3 4 6 1 6
の時は と を選ぶと最大公約数が となり、これが最大です。
の時は と を選ぶと最大公約数が となり、これが最大です。
の時は と を選ぶと最大公約数が となり、これが最大です。
の時は と を選ぶと最大公約数が となり、これが最大です。
の時は と を選ぶと最大公約数が となり、これが最大です。
入力例 2Copy
3 3 6 10 15
出力例 2Copy
1 1 1
入力例 3Copy
10 3 414003 854320 485570 52740 833292 625990 909680 885153 435420 221663
出力例 3Copy
59 590 590 879 879 590 20 879 590 59
Score : points
Problem Statement
You are given a sequence of length and a positive integer (at most ).
For each , solve the following problem:
- When you choose elements from that include , find the maximum possible GCD (greatest common divisor) of those chosen elements.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer for .
Sample Input 1Copy
5 2 3 4 6 7 12
Sample Output 1Copy
3 4 6 1 6
For , choosing and yields , which is the maximum.
For , choosing and yields , which is the maximum.
For , choosing and yields , which is the maximum.
For , choosing and yields , which is the maximum.
For , choosing and yields , which is the maximum.
Sample Input 2Copy
3 3 6 10 15
Sample Output 2Copy
1 1 1
Sample Input 3Copy
10 3 414003 854320 485570 52740 833292 625990 909680 885153 435420 221663
Sample Output 3Copy
59 590 590 879 879 590 20 879 590 59