Benelux Algorithm Programming Contest 2019(B)

Your parents decided that it would be “fun” to spend the entire Sunday walking near the Mookerheide close to Nijmegen.

Although you can pass the time by solving programming problems in your head, your siblings do not have the same luxury. After a short while, your younger sister Alice and your big brother Bob find themselves hopelessly bored. Together, they try to figure out if they can pass the time with a game (a problem that would later be referred to as the Bob and Alice Pastime Conundrum). Finally, they come up with the following simple game.



They find a single branch of length n that will be the main object of the game. Alternatingly, Alice and Bob choose a piece of branch and break it into two parts, in such a way that both parts have integer lengths. The last player who is able to break one of the pieces wins. Alice gets to start, as she is the younger of the two.

Of course, you already have the game figured out in your head. Assuming Bob plays optimally, can Alice win the game? And if so, what move should she make first?

input

A line containing a single integer 2 \le n \le 10^92≤n≤10 
9
 , the length of the branch.

output

On the first line print the name of the person who wins, Alice or Bob.

If Alice can win, print the length of a piece of branch Alice can break off as a winning move. This should be an integer between 1 and n−1n−1, inclusive.

If there are multiple valid solutions, you may output any one of them.

本题答案不唯一,符合要求的答案均正确

样例输入1复制
2
样例输出1复制
Alice
1
样例输入2复制
3
样例输出2复制
Bob

当时理解错题意了。。。以为只要能最后一个均分就胜利,没想到。。。
其实可以抽象成有n-1个点每次选择1个当选取后,所有点全部被取完,那么最后一个取点的人获胜。至于那个输出随意一个段长。。。我感觉有点诡异,但是输出1是肯定没错的,因为总是要全部折断成长度为一的段,所以直接取最后一步就行,但是对数据我保留疑惑。

#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

int main()
{
    int a;
    cin>>a;
    if(a % 2 == 0)
    {
        cout<<"Alice"<<endl<<1<<endl;
    }
    else
    {
        cout<<"Bob"<<endl;
    }
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值