img
Czech Technical University in Prague
ICPC Foundation
Czech ACM Chapter
Central Europe Regional Contest 2018
Game of Stones
stones.c, stones.cpp, Stones.java, stones.py
Two players, Petyr and Varys, play a game in which players remove stones from N piles in
alternating turns. Petyr, in his turn, can remove at most A stones from any pile. Varys, in his
turn, can remove at most B stones from any pile. Each player has to remove at least one stone
in his turn. The player who removes the last stone wins.
The game has already started and it is Petyr's turn now. Your task is to determine whether he
can win the game if both he and Varys play the game in the best possible way.
Input Specification
The first input line contains three integers N , A, and B (1 N 105 and 1 A, B 105 ). N
describes the number of piles and A, B represent Petyr's and Varys' restrictions. The second
line contains N integers X1, . . . , XN (1 Xi 106) specifying the current number of stones in
all piles.
Output Specification
Output the name of the winner.
Sample Input 1
Output for Sample Input 1
234
Petyr
23
Sample Input 2
Output for Sample Input 2
789
Varys
1234567