#P3339. [ZJOI2014] 取石子游戏

    ID: 2388 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>递推2014浙江进制斐波那契,Fibonacci

[ZJOI2014] 取石子游戏

Description

Roland P. Sprague and Patrick M. Grundy are both passionate enthusiasts of combinatorial games, but they have never met.

One day, in a letter to Grundy, Sprague introduced a supposedly ancient game from the East — Take-Stones.

Take-Stones is a two-player impartial game. At the beginning of the game, there are several piles of stones on the table. Then the players take turns: choose one pile and remove any positive number of stones from that pile (but you must take at least one). The player who cannot make a move loses, and the other player wins. Due to practical constraints, Sprague suggested writing a row of natural numbers on paper to represent the sizes of the piles, and then the two would take turns crossing out and writing numbers; Grundy gladly agreed.

A month passed, and after Grundy had lost 55 games in a row, he suspected that Sprague was cheating. After several days of study, one afternoon Grundy discovered that if both players are clever enough, then given an initial position (a row of natural numbers), there is a very simple way to determine whether the first player or the second player has a forced win, and even to provide a winning strategy! So Grundy decided to strike back.

The next day, in a letter to Sprague, Grundy suggested making the rules a bit more complicated: first fix a constant KK. Then each move is changed to: choose a number and cross it out. Suppose the chosen number is xx. The player may choose any positive integer a; after crossing out xx, they must write down xax-ax2ax-2a \cdotsxK×ax-K \times a — a total of KK numbers — and aa must satisfy xK×a0x-K\times a \geq 0. If no such a exists, then the player cannot cross out this number. A player still loses if and only if they have no legal move.

For the sake of pride, Sprague could not refuse. But he would not sit and wait for defeat either. He has already obtained the numbers written on the paper. He tells you this testdata and the rules of the game — you, a computer scientist studying how to use a not-yet-existing machine (which you name a “computer”) to solve practical problems in mathematics, physics, and economics.

Input Format

In the input file, the first line is a positive integer representing the number of test cases TT (the number of times Sprague consults you). Then TT test cases follow, each occupying N+2N + 2 lines, in the following format:

  • Line 11: an empty line.
  • Line 22: two positive integers, in order, representing NN and KK.
  • The next NN lines: each line contains one positive integer, representing the NN numbers written on the paper.

Output Format

The output file contains TT lines. For each test case, if the first player (the player who moves first) has a winning strategy, print Preempt.. If the second player has a winning strategy, print Leapfrog.. If neither of the above applies, print Je suis un imbecile..

2 
1 1 
1
2 30 
197943 
249832
Preempt.
Leapfrog.

Hint

10%10\% of the testdata satisfies: N5N \leq 5, K=1K=1, and all numbers are at most 55.

20%20\% of the testdata satisfies: N100N \leq 100, K=1K=1, and all numbers are at most 10910^9.

10%10\% of the testdata satisfies: N100N \leq 100, K=2K=2, and all numbers are at most 10910^9.

20%20\% of the testdata satisfies: N100N \leq 100, K=2K=2, and all numbers are at most 101810^{18}.

20%20\% of the testdata satisfies: N100N \leq 100, K=10K=10, and all numbers are at most 101810^{18}.

40%40\% of the testdata satisfies: N100N \leq 100, K=30K=30, and all numbers are at most 108010^{80}.

100%100\% of the testdata satisfies: T10T \leq 10.

Translated by ChatGPT 5