Kattis - multiplicationgame Multiplication Game 博弈因子相乘是否等于N

本文介绍了一种Alice和Bob在数学课上发明的乘法游戏。游戏开始时设定目标整数N(N≥2)和M=1。双方轮流选择N的一个质因数p,将M乘以p。若某一方通过操作使M等于N,则该方获胜;若M超过N,则游戏平局。给定输入案例,分析并确定在最优策略下谁会获胜或游戏是否平局。
摘要由CSDN通过智能技术生成

Alice and Bob are in their class doing drills on multiplication and division. They quickly get bored and instead decide to play a game they invented.

The game starts with a target integer N≥2, and an integer M=1. Alice and Bob take alternate turns. At each turn, the player chooses a prime divisor p of N, and multiply M by p. If the player’s move makes the value of M equal to the target N, the player wins. If M>N, the game is a tie.

Assuming that both players play optimally, who (if any) is going to win?

Input
The first line of input contains T (1≤T≤10000), the number of cases to follow. Each of the next T lines describe a case. Each case is specified by N (2≤N≤231−1) followed by the name of the player making the first turn. The name is either Alice or Bob.

Output
For each case, print the name of the winner (Alice or Bob) assuming optimal play, or tie if there is no winner.

Sample Input 1    Sample Output 1
10
10

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值