nimk博弈

1253.Problem A. Alice and Bob

Time Limit: 1000 MS    Memory Limit: 32768 KB
Total Submission(s): 11    Accepted Submission(s): 7

Description

Alice have a friend Bob, they like play games very much, They like to play games is to grab the stone, this classic game they play much times, so today they intend to make the classic reproduction, playing an overnight grab stone,  they are two people who like innovation, so this time they got a new game is played

a. There are N heap stones here.

b. Each time you can select stones that do not exceed M heap for any operation

c.   They play game in turns and cannot do nothing

d.   People who cannot move stones are losers

e.   Alice first

Input

The first line is T(0 < T <= 1000) T is TestCase

Next line is N, M(0 < N, M <= 10000)

Next line follow N number P, P is the number of stones in the stone heap(0 < P <= 10000)

Output

Case #TestCase: winner

If Alice win output Alice, otherwise Bob

Sample Input

15 11 2 3 4 5

Sample Output

Case #1: Alice

Source

Unknown

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int x[10005];
int maxx( int x, int y)
{
    if( x > y )
        return x;
    else
        return y;
}
int main()
{
    int t;
    scanf("%d", &t);
    int cnt = 1;
    while( t-- )
    {
        int ma = -1 , i;
        memset( x, 0, sizeof( x ));
        int n , m;
        scanf("%d%d", &n, &m);
        for( i = 0; i<n; i++)
        {
            int k = 0;
            int temp;
            scanf("%d", &temp);
            while( temp )
            {
                x[k++] += temp%2;///就是temp&2
                temp = temp/2;
            }
            ma =  maxx ( ma, k-1);
        }
        int flag  = 0;
        for( i = 0; i<=ma; i++)
        {
            if( x[i]%( m+1) != 0)
            {
                flag  = 1;
                printf("Case #%d: Alice\n", cnt++);
                break;
            }
        }
        if( flag == 0)
        {
            printf("Case #%d: Bob\n", cnt++);
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值