zoukankan      html  css  js  c++  java
  • Lightoj 1020

    Allice先拿,最后拿球的输。

    Bob先拿,最后拿球的赢。

    考虑Alice先拿球,当n=1时 Alice输  记dp[1]=0;

    n=2,  dp[2]=1

    n=3,  dp[3]=1

    因为n=1,2的时候先手是A,所以A可以通过选一个还是两个球使得B在n=2,3时输。

    n=4,  dp[4]=0

    因为n=2,3时B可能是先手,所以B可以通过选一个还是两个球使得A在n=4的时候输。

    n=5,dp[5]=1;

    n=6,dp[6]=1;

    因为n=4,5的时候先手是A,所以A可以通过选一个还是两个球使得B在n=5,6时输。

    .......

    dp[4]=dp[1]所以就可以看到规律了。。

    同理 Bob也用类似的想法。

    /* ***********************************************
    Author        :guanjun
    Created Time  :2016/6/24 22:49:21
    File Name     :1020.cpp
    ************************************************ */
    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    #include <stdio.h>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <iomanip>
    #include <list>
    #include <deque>
    #include <stack>
    #define ull unsigned long long
    #define ll long long
    #define mod 90001
    #define INF 0x3f3f3f3f
    #define maxn 10010
    #define cle(a) memset(a,0,sizeof(a))
    const ull inf = 1LL << 61;
    const double eps=1e-5;
    using namespace std;
    priority_queue<int,vector<int>,greater<int> >pq;
    struct Node{
        int x,y;
    };
    struct cmp{
        bool operator()(Node a,Node b){
            if(a.x==b.x) return a.y> b.y;
            return a.x>b.x;
        }
    };
    
    bool cmp(int a,int b){
        return a>b;
    }
    int main()
    {
        #ifndef ONLINE_JUDGE
        freopen("in.txt","r",stdin);
        #endif
        //freopen("out.txt","w",stdout);
        int T,n;
        cin>>T;
        string s1,s2;
        for(int t=1;t<=T;t++){
            cin>>n>>s1;
            printf("Case %d: ",t);
            if(s1=="Alice"){
                if(n%3==1)puts("Bob");
                else puts("Alice");
            }
            else{
                if(n%3==0)puts("Alice");
                else puts("Bob");
            }
        }
        return 0;
    }
  • 相关阅读:
    __weak
    c++界面设计皮肤工具
    执行游戏时出现0xc000007b错误的解决方法
    2.4.1-Java语言基础(常量)
    句法模式识别(一)-串文法
    一步一步写算法(之hash表)
    LaTeX新人教程,30分钟从全然陌生到基本入门
    初次当面试官的经历和感触
    Android入门第八篇之GridView(九宫图)
    Android-Cannot merge new index 66195 into a non-jumbo instruction的解决的方法
  • 原文地址:https://www.cnblogs.com/pk28/p/5615620.html
Copyright © 2011-2022 走看看