eolymp
bolt
Try our new interface for solving problems
Məsələlər

Red John Game

Red John Game

Red John has a chess table of infinite dimensions, and \textbf{n}×\textbf{n} pawns, arranged in an \textbf{n}×\textbf{n} square. The pawns can be moved horizontally or vertically, buy jumping over an (horizontally or vertically) adjacent pawn, and onto the next position, only if this position is unoccupied by another pawn. Also, when a valid move occurs, the jumped pawn is removed. Can you help Red John figure out if there is a sequence of moves which leaves only one pawn on the table ? Below, such a sequence of moves is illustrated, for \textbf{n = 2}. Pawns are depicted by the letter \textbf{P}. \includegraphics{https://static.e-olymp.com/content/f0/f00d1e3aa331e91ff1b95e694e9175ad04285124.jpg} \InputFile The program input is from a text file. Each file contains a value for \textbf{n}, with \textbf{0} < \textbf{n} < \textbf{10^9}. \OutputFile The output consists of \textbf{1} if there is a sequence of moves leaving only one pawn on the table, and \textbf{0} otherwise. There cannot be any whitespace and newline characters in the output. Two examples of input/output pairs are shown below.
Zaman məhdudiyyəti 0.5 saniyə
Yaddaşı istafadə məhdudiyyəti 256 MiB
Giriş verilənləri #1
3
Çıxış verilənləri #1
0
Mənbə ACM SEERC 2013, SouthEastern European Region, October, 12/10/2013, Vinnica & Bucharest