#P16508. [GKS 2015 #B] gNumbers
[GKS 2015 #B] gNumbers
题目描述
Googlers are crazy about numbers and games, especially number games! Two Googlers, Laurence and Seymour, have invented a new two-player game based on "gNumbers". A number is a gNumber if and only if the sum of the number's digits has no positive divisors other than 1 and itself. (In particular, note that is a gNumber.)
The game works as follows: First, someone who is not playing the game chooses a starting number . Then, the two players take turns. On a player's turn, the player checks whether the current number C is a gNumber. If it is, the player loses the game immediately. Otherwise, the player chooses a prime factor P of C, and keeps dividing C by P until P is no longer a factor of C. (For example, if the current number were 72, the player could either choose and repeatedly divide by until reaching , or choose and repeatedly divide by until reaching .) Then the result of the division becomes the new current number, and the other player's turn begins.
Laurence always gets to go first, and he hates to lose. Given a number , he wants you to tell him which player is certain to win, assuming that both players play optimally.
输入格式
The first line of the input gives the number of test cases, . test cases follow; each consists of a starting number .
输出格式
For each test case, output one line containing "Case #x: y", where is the test case number (starting from 1) and is the winner's name: either Laurence or Seymour.
9
2
3
4
6
8
9
30
36300
1000000000000000
Case #1: Seymour
Case #2: Seymour
Case #3: Laurence
Case #4: Laurence
Case #5: Laurence
Case #6: Laurence
Case #7: Seymour
Case #8: Laurence
Case #9: Seymour
提示
In Case #1, is already a gNumber, since the sum of its digits is , which has no positive divisors other than and itself. So Laurence immediately loses, which means Seymour wins. The same is true for Case #2.
In Case #3, is not a gNumber, since the sum of its digits is , which has a positive divisor other than and itself (namely, ). has one prime factor (), so Laurence must choose this factor and repeatedly divide by it, which leaves him with . Then, Seymour begins his turn with , which is a gNumber. So he loses and Laurence wins.
Limits
.
Small dataset (Test Set 1 - Visible)
.
Large dataset (Test Set 2 - Hidden)
.