Prime Game
Time limit2sMemory limit256 MB
Simulate a two-player game where each spoken prime is recorded per player, duplicates cost 1000 points, and a non-prime gives the opponent their third largest prime or 1000.
- Level
Medium4 of 10
- Topics
- Simulation, Implementation, Number theory, Sorting
- Solved
- No attempts yet
Problem
Daewoong, a student at Inha University, loves number theory. At some point he started memorizing primes, and now he can tell whether any number he hears is prime. When a rumor spread that Inha University has a god of primes, Gyuseong, the prime master of Insang University, challenged Daewoong.
The two decided to bet on who loves primes more. Since there is no way to measure that directly, they settle it with the prime game.
The rules of the prime game are as follows.
- The two players take turns saying one number each.
- When a player says a number that is not prime, the opponent gains points. The opponent gains the third largest of the primes the opponent has said so far. If the opponent has said fewer than 3 primes so far, the opponent gains 1000 points instead.
- If a player says a prime that has already appeared at least once, that player gets points, and the prime is not recorded as one of that player's primes.
- Gyuseong is the challenger, so Daewoong always moves first.
- Every number the players say is less than .
0 and 1 are not prime. Both players start with 0 points. Print the winner of the prime game played under these rules.
Input
The first line contains , the number of rounds. ()
Each of the next lines contains the integers said by Daewoong and Gyuseong in that round, in this order, separated by a space. In each round Daewoong speaks first and Gyuseong speaks second. Every integer is at least and less than .
Output
After all rounds, the player with the higher score wins. Print 소수의 신 갓대웅 if Daewoong wins and 소수 마스터 갓규성 if Gyuseong wins. If the scores are equal, print 우열을 가릴 수 없음. Print these Korean strings exactly as shown.