简单博弈。
以下是我的代码:
/*
* Author: lee1r
* Created Time: 2011/8/4 8:56:39
* File Name: uva10407.cpp
*/
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#define L(x) ((x)<<1)
#define R(x) (((x)<<1)+1)
#define Half(x) ((x)>>1)
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int kInf(0x7f7f7f7f);
const double kEps(1e-11);
typedef long long int64;
typedef unsigned long long uint64;
const int kMaxn(1000007);
int n,m,r[kMaxn];
bool d[kMaxn];
int main()
{
//freopen("data.in","r",stdin);
while(scanf("%d%d",&n,&m)==2)
{
for(int i=1;i<=m;i++)
scanf("%d",&r[i]);
d[0]=false;
for(int i=1;i<=n;i++)
{
d[i]=false;
for(int j=1;j<=m;j++)
if(i-r[j]>=0)
if(d[i-r[j]]==false)
{
d[i]=true;
break;
}
}
if(d[n])
printf("Stan wins\n");
else
printf("Ollie wins\n");
}
return 0;
}
posted on 2011-08-04 09:33
lee1r 阅读(567)
评论(0) 编辑 收藏 引用 所属分类:
题目分类:动态规划