Codeforces Round 499 (Div. 2)
E
Border
Codeforces
未评级
原题
← DF →
翻译中…

Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territory of Mars.

翻译中…

There are $n$ banknote denominations on Mars: the value of $i$-th banknote is $a_i$. Natasha has an infinite number of banknotes of each denomination.

翻译中…

Martians have $k$ fingers on their hands, so they use a number system with base $k$. In addition, the Martians consider the digit $d$ (in the number system with base $k$) divine. Thus, if the last digit in Natasha's tax amount written in the number system with the base $k$ is $d$, the Martians will be happy. Unfortunately, Natasha does not know the Martians' divine digit yet.

翻译中…

Determine for which values $d$ Natasha can make the Martians happy.

翻译中…

Natasha can use only her banknotes. Martians don't give her change.

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $k$ ($1 \le n \le 100\,000$, $2 \le k \le 100\,000$) — the number of denominations of banknotes and the base of the number system on Mars.

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$) — denominations of banknotes on Mars.

翻译中…

All numbers are given in decimal notation.

翻译中…

Output

翻译中…

On the first line output the number of values $d$ for which Natasha can make the Martians happy.

翻译中…

In the second line, output all these values in increasing order.

翻译中…

Print all numbers in decimal notation.

翻译中…

Note

翻译中…

Consider the first test case. It uses the octal number system.

翻译中…

If you take one banknote with the value of $12$, you will get $14_8$ in octal system. The last digit is $4_8$.

翻译中…

If you take one banknote with the value of $12$ and one banknote with the value of $20$, the total value will be $32$. In the octal system, it is $40_8$. The last digit is $0_8$.

翻译中…

If you take two banknotes with the value of $20$, the total value will be $40$, this is $50_8$ in the octal system. The last digit is $0_8$.

翻译中…

No other digits other than $0_8$ and $4_8$ can be obtained. Digits $0_8$ and $4_8$ could also be obtained in other ways.

翻译中…

The second test case uses the decimal number system. The nominals of all banknotes end with zero, so Natasha can give the Martians only the amount whose decimal notation also ends with zero.

翻译中…

样例

Input #1
2 8
12 20
Output #1
2
0 4
InputCopy OutputCopy
Input #2
3 10
10 20 30
Output #2
1
0
InputCopy OutputCopy
题目信息
题号
1011E
时间限制
1 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。