HDU 1846 Brave Game 博弈水题

题目大意:

就是简单的取石子游戏....n个石子两个人每次可以去1~m个, 取走最后的胜利


大致思路:

如果n % (m + 1) == 0后手胜, 否则先手胜...没什么好解释的了...


代码如下:

Result  :  Accepted     Memory  :  1620 KB     Time  :  0 ms

/*
 * Author: Gatevin
 * Created Time:  2015/4/28 21:06:00
 * File Name: Rin_Tohsaka.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>
#include<iomanip>
using namespace std;
const double eps(1e-8);
typedef long long lint;
#define foreach(e, x) for(__typeof(x.begin()) e = x.begin(); e != x.end(); ++e)
#define SHOW_MEMORY(x) cout<<sizeof(x)/(1024*1024.)<<"MB"<<endl

int T;
int n, m;
int main()
{
    scanf("%d", &T);
    while(T--)
    {
        scanf("%d %d", &n, &m);
        if(n % (m + 1) == 0) puts("second");
        else puts("first");
    }
    return 0;
}


你可能感兴趣的:(game,HDU,Brave,简单博弈,1846)