zoukankan      html  css  js  c++  java
  • ENimEN

    In deterministic games no chance is involved, meaning that the final result can be predicted from the
    initial arrangement assuming players play optimal. These games are so boring.
    piloop and poopi are professional gamers. They play games only to study their algorithmic properties.
    Their field of expertise is boring games. One of the boring games they often play is Nim. Nim
    is a two-player game which is played using distinct heaps, each containing a number of objects (e.g.
    stones). Players take turns removing non-zero number of objects from a heap of their choice. The
    player who removes the last object will win.
    They wonder if they can change the game to make it more fascinating. Would not that be more
    interesting if make the rules stricter? For example what if each player is obliged to take objects from
    the last non-empty heap as his opponent took objects from. And if there is no such heap, he can choose
    one heap freely and take objects from it. ENimEN is their new invented game based on this rule.
    If you are interested in ENimEN, write a program to determine the winner given the initial arrangement
    assuming both players, play optimal. We believe it has also some benefits for you!
    Input
    The first line contains T (T ≤ 100), the number of test cases. Each test begins with an integer N
    (N ≤ 20000) in the first line, the number of heaps followed by N integers ai (1 ≤ ai ≤ 109
    ), are the
    number of objects in i-th heap.
    Output
    If in the optimal strategy the first player is the winner print ‘poopi’ (as he always plays first), otherwise
    print ‘piloop’. (Quotes for clarity)
    Sample Input
    2
    2
    1 1
    4
    1 2 1 1
    Sample Output
    piloop
    poopi

    还是一道博弈论的水题。。。

    #include<cstdio>
    using namespace std;
    int main(){int T,n,x;bool h=0;
        scanf("%d",&T);
        while(T--){scanf("%d",&n);
            for(int i=0;i<n;i++){scanf("%d",&x);if(x!=1){h=1;}}
            if(h==1)printf("poopi
    ");
            else {if(n%2==0)printf("piloop
    ");else printf("poopi
    ");}h=0;}}
  • 相关阅读:
    [转].net自定义验证控件CustomValidator的使用
    After Effects CS4入门经典—高手之路
    [转]用JS获取地址栏参数的方法(超级简单)
    SpringBoot中通过SpringBootServletInitializer如何实现容器初始化
    SpringBoot之二:部署Spring Boot应用程序方式
    Zookeeper学习(八):Zookeeper的数据发布与订阅模式
    Dubbo各种协议详解
    Annotation之四:注解中的-Xlint:unchecked和 -Xlint:deprecation
    mina在spring中的配置多个端口
    Mina2中IoService
  • 原文地址:https://www.cnblogs.com/muzu/p/7149457.html
Copyright © 2011-2022 走看看