#P44. [KBC003D] Flu 2
[KBC003D] Flu 2
Source
This problem is adapted from Long Long OJ. All rights reserved.
Problem Background
In the distant Gensokyo, an outbreak of idiocy flu has occurred.
Problem Description
There are residents living in Gensokyo, each with a unique and distinct personal ID number ranging from to .
On the first day, people are infected, and we know their IDs. In the subsequent days, a person with ID will be infected on a certain day if and only if:
- Some resident was infected on the previous day;
- Some resident was infected on the first day (note: and can be the same here);
- and satisfy the condition: .
Each resident can be infected repeatedly! Please write a program to find out which people will be infected on the -th day.
Input Format
- The first line contains three integers ;
- The second line contains integers representing the IDs of people infected on the first day.
Output Format
Output a line with several integers, representing the IDs of people infected on the -th day (output in ascending order).
Samples
1 100 3
1 2 3
1 2 3
2 100 3
1 2 3
1 2 3 4 6 9
3 101 2
5 50
24 38 63 77
Data Range
For 100% of the data: , , .