#P16508. [GKS 2015 #B] gNumbers

    ID: 16485 Type: RemoteJudge 2000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 7 Uploaded By: Tags>2015状压 DPGoogle Kick Start

[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 11 is a gNumber.)

The game works as follows: First, someone who is not playing the game chooses a starting number NN. 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 22 and repeatedly divide by 22 until reaching 99, or choose 33 and repeatedly divide by 33 until reaching 88.) 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 NN, 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, TT. TT test cases follow; each consists of a starting number NN.

输出格式

For each test case, output one line containing "Case #x: y", where xx is the test case number (starting from 1) and yy 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, 22 is already a gNumber, since the sum of its digits is 22, which has no positive divisors other than 11 and itself. So Laurence immediately loses, which means Seymour wins. The same is true for Case #2.

In Case #3, 44 is not a gNumber, since the sum of its digits is 44, which has a positive divisor other than 11 and itself (namely, 22). 44 has one prime factor (22), so Laurence must choose this factor and repeatedly divide 44 by it, which leaves him with 11. Then, Seymour begins his turn with 11, which is a gNumber. So he loses and Laurence wins.

Limits

1T1001 \le T \le 100.

Small dataset (Test Set 1 - Visible)

1<N10001 < N \le 1000.

Large dataset (Test Set 2 - Hidden)

1<N10151 < N \le 10^{15}.