• 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;
    }
  • 相关阅读:
    获取用户登录次数(cookie)
    漂亮的 Checkbox and Radio (jQuery)
    FancyUpload3.0
    UI upload 多文件上传
    js 匿名函数 闭包
    c# 图片插入Excel
    sql查询优化 索引优化
    GridViewAddUpdateDelete_Ajax with jquery.blockUI
    动态自动搜索 Dynamic search (js版)
    master.dbo.spt_values
  • 原文地址:https://www.cnblogs.com/lanjiangzhou/p/3016971.html
Copyright © 2020-2023  润新知