zoukankan      html  css  js  c++  java
  • 11892

    UVA 11892 - ENimEN

    题目链接

    题意:给定n堆石头。两人轮流取,每次仅仅能取1堆的1到多个。假设上一个人取了一堆没取完。那么下一个人必须继续取这堆。取到最后一个石头的赢,问谁赢

    思路:简单推理一下。后手仅仅可能在堆数偶数而且都是1的情况下才可能赢

    代码:

    #include <stdio.h>
    #include <string.h>
    
    const int N = 20005;
    int t, n, a[N];
    
    bool judge() {
    	if (n % 2) return false;
    	for (int i = 0; i < n; i++)
    		if (a[i] != 1) return false;
    	return true;
    }
    
    int main() {
    	scanf("%d", &t);
    	while (t--) {
    		scanf("%d", &n);
    		for (int i = 0; i < n; i++)
    			scanf("%d", &a[i]);
    		if (judge()) printf("piloop
    ");
    		else printf("poopi
    ");
     	}
    	return 0;
    }


  • 相关阅读:
    spring cloud教程
    ideaaaaaaaaa
    Django
    Django 基础介绍
    Pychram
    python
    python
    python
    Python
    Python -- Scrapy 命令行工具(command line tools)
  • 原文地址:https://www.cnblogs.com/llguanli/p/6878163.html
Copyright © 2011-2022 走看看