• 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;
    }
  • 相关阅读:
    神经网络学习之----单层感知器
    神经网络学习之----神经网络发展史
    神经网络学习之----神经网络概述
    C语言几种常见的字符串输入
    基于单链表实现集合的交集、并集、差集的运算
    关于单链表的一些基本操作
    输入20个整数存放到一个单向链表中,并顺序逆序输出
    《你的灯亮着吗》阅读笔记
    场景调研
    站立会议总结09
  • 原文地址:https://www.cnblogs.com/pk28/p/5615620.html
Copyright © 2020-2023  润新知