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;
}
Cu1
发布了30 篇原创文章 · 获赞 2 · 访问量 952

猜你喜欢

转载自blog.csdn.net/CUCUC1/article/details/105021241