A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 易孟飞 中级黑马   /  2014-10-6 01:31  /  1074 人查看  /  6 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

黑马提供的视频全部下载完毕,破网速,竟然用了快三天,继续努力,尽快看完

6 个回复

正序浏览
happyto1021 来自手机 中级黑马 2014-10-6 12:18:56
7#
加油。。。。
回复 使用道具 举报
陌生爱人 发表于 2014-10-6 10:53
刚下载完毕 就10技术分了  我视频刚看完 现在才1技术分 情何以堪

一起继续努力吧
回复 使用道具 举报
明天过后1 发表于 2014-10-6 11:18
帖子能再水点么?发点问题来玩玩啊!

骚年有想法,扔你个ACM动动你的无敌大脑吧,
Background

Christiane and Matthias are playing a new game, the Number Game. The rules of the Number Game are:

Christian and Matthias take turns in choosing integer numbers greater than or equal to 2. The following rules restrict the set of numbers which may be chosen:

R1 A number which has already been chosen by one of the players or a multiple of such a number cannot be chosen. (A number z is a multiple of a number y if z can be written as y * x and x is a positive integer.)

R2 A sum of two such multiples cannot be chosen either.

R3 For simplicity, a number which is greater than 20 cannot be chosen either. This enables a lot more NPCs (Non-Personal-Computers) to play this game.

The player who cannot choose any number anymore looses the Number Game.

Here is an example: Matthias starts by choosing 4. Then Christiane is not allowed to choose 4, 8, 12, etc. Let us assume her move is 3. Now, the numbers 3, 6, 9, etc. are excluded, too; furthermore, numbers like: 7 = 3 + 4, 10 = 2 * 3 + 4, 11 = 3 + 2 * 4, 13 = 3 * 3 + 4, . . . are not available. So, in fact, the only numbers left are 2 and 5. Matthias now says 2. Since 5 = 2 + 3 is now forbidden, too, he wins because there is no number for Christiane's move left.

Your task is to write a program which will help to play the Number Game. In general, i.e., without rule R3, this game may go on forever. However, with rule R3, it is possible to write a program that finds a strategy to win the game.


Problem

Given a game situation (a list of numbers which are not yet forbidden), your program should output all winning moves. A winning move is a move by which the player whose turn it is can force a win no matter what the other player will do. Now we define these terms more formally:

A loosing position is a position in which either

1. all numbers are forbidden, or

2. no winning move exists.

A winning position is a position in which a winning move exists.

A winning move is a move after which the position is a loosing position.


Input

The first line contains the number of scenarios.

The input for each scenario describes a game position. It begins with a line containing the number a, 0 <= a < 20 of numbers which are still available. Next follows a single line with the a numbers still available, separated by single blanks.

You may assume that all game positions in the input could really occur in the Number Game (for example, if 3 is not in the list of numbers available, 6 will not be, either).


Output

The output for each scenario begins with a line containing "Scenario #i:" where i is the number of the scenario starting at 1. In the next line either print "There is no winning move." if this is true for the position of the current scenario, or "The winning moves are: w1 w2 . . . wk." where the wi are all the winning moves, in ascending order, separated by single blanks. The output for each scenario should be followed by a blank line.


Sample Input

2
1
2
2
2 3


Sample Output

Scenario #1:
The winning moves are: 2.

Scenario #2:
There is no winning move.
//我是搞不定它
回复 使用道具 举报
帖子能再水点么?发点问题来玩玩啊!
回复 使用道具 举报
那么大,还不如看一点,下一点
回复 使用道具 举报
刚下载完毕 就10技术分了  我视频刚看完 现在才1技术分 情何以堪
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马