当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5218:Game

题目描述
BrotherK is very rich. He has a big company.

One day, BrotherK wants to give an award to one of the employees in the company. It's so hard to make a choise that BrotherK decides to play a game to determine the lucky dog.

At the beginning of the game, all $N$ employees form a circle. Then, they receive t-shirts with numbers 1 through $N$ in clockwise order along the circle.

The game consists of many turns. In the ith turn, BrotherK starts by standing in front of a employee and announces a number $X_i$. He will move to the ($X_i+1$)th-next-employee in clockwise order, and the $X_i$th-next-employees will be removed from the circle, then the (i+1)th turn starts.

Attention that the 1th-next-employee of a employee is itself, and BrotherK stands in front of the employee with number 1 at first. In the ith turn, The value of $X_i$ is chosen randomly from a given integer set $S$. When there is only one employee left in the game, the game ends and the employee wins the award.

You are given the int $N$ and the set of integers, BrotherK wants to know which employees are possible to win.
输入解释
The first line contains a single integer $T$, indicating the number of test cases.

Each test case begins with two integer $N, M$, indicating the number of employees in BrotherK's company, and the size of BrotherK's integer set $S$. Next line contains $M$ numbers, from $a_1$ to $a_M$, indicating the integer in $S$.

$T$ is about 50

$1~\le~N, M~\le~200$

$1~\le~a_i~\le~10^9$
输出解释
For each test, print two lines.

The first line contains a integer $K$, indicating how many people are possible to win.

The second line contains $K$ number, indicating the number in T-shirt who can win, in ascending order.
输入样例
2
3 1
1
3 2
1 2
输出样例
1
3
3
1 2 3
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5218

最后修改于 2020-10-25T23:20:47+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 131072/131072K(Java/Others)