408513: GYM103176 F Find the Base

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Find the Basetime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Today, Bob learned how to write a number in binary representation. Moreover, he learned that he can express a number not only in decimal or binary, but also in octal, in hexadecimal, or even in any bases greater than 1! As Bob is a hardworking student, he wants to revise what he has learned today. Therefore, he would like to express numbers in different bases!

There are $$$N$$$ integers written on Bob's notebook and he has a favorite number $$$M$$$. He tries to express all $$$N$$$ integers in every base from $$$2$$$ to $$$B$$$. Suddenly, he realizes that when he writes those $$$N$$$ integers in some bases, the digit sum of some integers may become equal to his favorite number $$$M$$$! As $$$M$$$ is his favorite number, the more numbers having digit sum equal to $$$M$$$, the more he loves that base. Formally, among all the bases from $$$2$$$ to $$$B$$$, base $$$x$$$ is one of his favorites if, when all $$$N$$$ integers are expressed in base $$$x$$$, the number of integers which has a digit sum of $$$M$$$ is maximal.

Noted that in this task, in base $$$i$$$, digits of number are represented as {0, 1, 2, ... , $$$i$$$ - 1} instead of {0, 1, 2, ... , 9, A, B, C, ... }. So 26 in base 14, i.e. 1(12), has digit sum of $$$1 + 12 = 13$$$.

Being a curious person, Bob wants to find out all of his favorite bases. However, he just learned about number systems other than decimal for one day and doesn't familiar with expressing numbers in other representations. So, he wants you to help him to find out all of his favorite bases.

Input

The first line consists of three integers, $$$N$$$, $$$M$$$ and $$$B$$$. ($$$1\le N, M \le 10^5$$$, $$$2 \le B \le 10^5$$$.

The second line consists of $$$N$$$ integers, which is the numbers written on Bob's notebook. The $$$i^{th}$$$ integer correspond to $$$A_i$$$, $$$1 \le A_i\le 10^5$$$.

Output

The first line consists of one integer, $$$K$$$, the number of Bob's favorite bases.

The second line consists of $$$K$$$ integers, all of Bob's favorite bases. Please print the answer in the ascending order.

ExamplesInput
3 3 5
1 3 12
Output
1
4
Input
8 3 15
1 2 2 3 5 16 18 26
Output
3
4 6 14
Note

In the first sample, A[] = {1, 3, 30} in base 4, which has 2 number with digit sum of 3, which is maximal among bases from $$$2$$$ to $$$5$$$.

加入题单

算法标签: