hdu 1846巴什博奕

http://acm.hdu.edu.cn/showproblem.php?pid=1846

好几天没出题了,今天终于水了一题巴什博弈题。

总结:

【一】巴什博弈

 对象:一堆石子(可延伸

 重要公式:N=(M+1)*r+s

 S不为0的话,先手必赢

思维拓展(先手必赢):较为简单,就是去掉一堆石子N中(比最高可取的数目M再多1的倍数)的数目的余数S, 

让对方每次只能最多拿掉M个石子,但是这个回合中先手就可以能把剩下的(这个回合的)拿去了。简单吧~~嘻嘻

套公式就行了。

博弈第一题,mark一下。

View Code
// I'm lanjiangzhou
//C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
//C++
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <map>
#include <vector>
#include <deque>
#include <set>
using namespace std;

//*************************OUTPUT*************************
#ifdef WIN32
#define INT64 "%I64d"
#define UINT64 "%I64u"
#else
#define INT64 "%lld"
#define UINT64 "%llu"
#endif

//**************************CONSTANT***********************
#define INF 0x3f3f3f3f

// aply for the memory of the stack
//#pragma comment (linker, "/STACK:1024000000,1024000000")
//end


int main(){
    int n,m,t;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&m);
        int s;
        s=n%(m+1);
        if(s!=0){
            printf("first\n");
        }
        else printf("second\n");
    }
    return 0;
}

 

posted @ 2013-04-12 16:49  南下的小程序员  阅读(145)  评论(0编辑  收藏  举报