题库练习 Border
← 上一题 下一题 →

A11914 | Border

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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.

输入格式

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.

输出格式

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.

输入输出样例

输入 #1
2 8
12 20
输出 #1
2
0 4 
输入 #2
3 10
10 20 30
输出 #2
1
0 
C++ 编辑器
输入
输出