#P3339. [ZJOI2014] 取石子游戏
[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 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 . Then each move is changed to: choose a number and cross it out. Suppose the chosen number is . The player may choose any positive integer a; after crossing out , they must write down ,,, — a total of numbers — and must satisfy . 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 (the number of times Sprague consults you). Then test cases follow, each occupying lines, in the following format:
- Line : an empty line.
- Line : two positive integers, in order, representing and .
- The next lines: each line contains one positive integer, representing the numbers written on the paper.
Output Format
The output file contains 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
of the testdata satisfies: , , and all numbers are at most .
of the testdata satisfies: , , and all numbers are at most .
of the testdata satisfies: , , and all numbers are at most .
of the testdata satisfies: , , and all numbers are at most .
of the testdata satisfies: , , and all numbers are at most .
of the testdata satisfies: , , and all numbers are at most .
of the testdata satisfies: .
Translated by ChatGPT 5
京公网安备 11011102002149号