Logo
(追記) (追記ここまで)

34477번 - Blackboard Game 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB299746.667%

문제

To help her elementary school students understand the concept of prime factorization, Aisha has invented a game for them to play on the blackboard. The rules of the game are as follows.

The game is played by two players who alternate their moves. Initially, the integers from 1ドル$ to $n$ are written on the blackboard. To start, the first player may choose any even number and circle it. On every subsequent move, the current player must choose a number that is either the circled number multiplied by some prime, or the circled number divided by some prime. That player then erases the circled number and circles the newly chosen number. When a player is unable to make a move, that player loses the game.

To help Aisha’s students, write a program that, given the integer $n,ドル decides whether it is better to move first or second, and if it is better to move first, figures out a winning first move.

입력

The first line of input contains an integer $t$ (1ドル ≤ t ≤ 40$), which is the number of test cases. The descriptions of $t$ test cases follow.

Each test case consists of a single line containing an integer $n$ (2ドル ≤ n ≤ 10^7$), which is the largest number written on the blackboard.

Over all test cases, the sum of $n$ is at most 10ドル^7$.

출력

For each test case, if the first player has a winning strategy for the given $n,ドル output the word first, followed by an even integer – any valid first move that can be extended to a winning strategy. If the second player has a winning strategy, output just the word second.

제한

예제 입력 1

1
5

예제 출력 1

second

For $n = 5,ドル the first player loses the game regardless of the first move.

  • If the first player starts with 2ドル,ドル the second player circles 4ドル,ドル and there are no more valid moves left.
  • If the first move is 4ドル,ドル the second player circles 2ドル$. The first player must then circle 1ドル,ドル and the second player may pick either of the remaining two numbers (3ドル$ or 5ドル$) to win.

예제 입력 2

2
12
17

예제 출력 2

first 8
first 6

노트

출처

ICPC > World Finals > ICPC World Finals 2025 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /