HDU4642博弈好题

来源:互联网 发布:mbc电视台网络直播 编辑:程序博客网 时间:2024/05/01 07:31

链接:http://acm.hdu.edu.cn/

两个人进行翻棋游戏,若a[n][m]为1,则不管先手就可以翻a[n][m]使其为0,这样不管后手翻什么都会使得a[n][m]为1,先手总是有棋可翻;而若a[n][m]为0,先手 总会面临无棋可翻的状态,因此只需要判断a[n][m]的值即可求解

#include<iostream>#include<cstdio>using namespace std;const int maxn=100+10;int a[maxn][maxn];int main(){    int t;    cin>>t;    while(t--)    {        int n,m;        scanf("%d%d",&n,&m);        for(int i=1;i<=n;i++)            for(int j=1;j<=m;j++)            scanf("%d",&a[i][j]);        if(a[n][m]==1)            printf("Alice\n");        else            printf("Bob\n");    }    return 0;}



0 0
原创粉丝点击