HUBULLU - Hubulullu

no tags 

After duelling in quake (a multiplayer game), Airborne and Pagfloyd decide do test themselves out in another game called Hubulullu. The rules of the game are as follows:

N wooden pieces (marked with numbers 1 to N) are placed in a transparent bottle. On his turn the first player takes out some piece (numbered x) and all the pieces numbered by divisors of x that are present in the transparent bottle. The second player picks another number and removes it and its divisors as well. Play continues in an alternating fashion until all pieces have been removed from the bottle. The player who removes the last piece from the bottle wins the game.

Both players play optimally. Given N (the number of wooden pieces in the transparent bottle initially) and the name of the player who starts the game, determine the winner.


The first line of the input contains an integer t, the number of test cases. t test cases follow.

Each test case consists of a single line containing two integers separated by a single space. The first integer is N (1 <= N <= 2000000000), indicating the number of pieces, and the second integer indicates the player who starts - "0" means Airborne starts the game and "1" means Pagfloyd starts the game (quotes for clarity).


For each test case output one line containing either "Airborne wins." or "Pagfloyd wins."

For each N, it's possible to determine a winner if both players play optimally.


1 0

Airborne wins.

hide comments
Jumpy: 2019-03-23 09:04:25

In the beginning, I was thinking of some tough pattern. later on, some observation told, it has nothing to do with the value of N.

shubham_03: 2019-01-04 19:28:10

Just required observation and the rest is easy...

salman3007: 2018-10-15 04:10:58

the optimal strategy would be that each player must ensure that even no. of sets of coprime numbers are passed to the next round.

vivek_dwivedi: 2018-06-26 10:51:06

great problem ! those who are saying its easy they just solved with pattern. try to prove it .its fun

r210397: 2018-06-23 20:46:10

the word optimally is important no algo not pattern no implementation

venkat016: 2018-01-11 17:15:24

Waste of time.

piyush490: 2017-12-30 13:19:07

much easy

sushantoberoi3: 2017-04-07 16:15:26

try something like proof by contradiction...

the_novice96: 2017-04-06 11:54:33

Can be solved using the very basics of game theory. Proof is amazing. But the problem could have been wrapped in a better statement.

avi_pandey: 2017-03-03 21:09:42

ooo yeeah!!
its my 50th on spoj.

Added by:Matthew Reeder
Time limit:1.787s
Source limit:30000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:Al-Khawarizm 2006