Codeforces Problem -451 A. Game With Sticks (水题 博弈)

题目链接

题意:水平n,竖直m根杆有n*m个节点,先手A走到某个节点然后去掉该点的水平竖直杆,无点可走的时候输

推测了几组然后猜到结果:

1 2 先赢

2 2先输

2 3 先输

3 3 先赢

就是看min(n,m)的奇偶性;(我推的要麻烦一点)

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    while(cin>> n >> m){
        int x = min(n,m);
        if(x%2) cout<<"Akshat"<<endl;//先手赢
        else cout<<"Malvika"<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_42754600/article/details/81781058
今日推荐