zoj3057 Beans Game

16 篇文章 0 订阅
Beans Game

Time Limit: 5 Seconds Memory Limit: 32768 KB

There are three piles of beans. TT and DD pick any number of beans from any pile or the same number from any two piles by turns. Who get the last bean will win. TT and DD are very clever.

Input

Each test case contains of a single line containing 3 integers a b c, indicating the numbers of beans of these piles. It is assumed that 0 <= a,b,c <= 300 and a + b + c > 0.

Output

For each test case, output 1 if TT will win, ouput 0 if DD will win.

Sample Input

1 0 0
1 1 1
2 3 6

Sample Output

1
0
0
本想找什么归律什么,但这题好卡时间和内存,没想到直接这样打表就可以了!
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
#define M 301
bool dp[M][M][M]={0};
void init(){
    int i,j,k,a,b,c;
    for(i=0;i<M;i++)
    for(j=0;j<M;j++)
    for(k=0;k<M;k++)
        if(!dp[i][j][k]){
            for(a=1;i+a<M;a++)
            dp[i+a][j][k]=1;
            for(a=1;j+a<M;a++)
            dp[i][j+a][k]=1;
            for(a=1;k+a<M;a++)
            dp[i][j][k+a]=1;
            for(a=1;i+a<M&&j+a<M;a++)
            dp[i+a][j+a][k]=1;
            for(a=1;j+a<M&&k+a<M;a++)
            dp[i][j+a][k+a]=1;
            for(a=1;i+a<M&&k+a<M;a++)
            dp[i+a][j][k+a]=1;
        }
}
int main()
{
    int a,b,c;
    init();
    while(scanf("%d%d%d",&a,&b,&c)!=EOF){
        printf("%d\n",dp[a][b][c]);
    }
    return 0;
}


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值