Being a Good Boy in Spring Festival(博弈)

Being a Good Boy in Spring Festival
 

Problem Description
一年在外 父母时刻牵挂
春节回家 你能做几天好孩子吗
寒假里尝试做做下面的事情吧

陪妈妈逛一次菜场
悄悄给爸爸买个小礼物
主动地 强烈地 要求洗一次碗
某一天早起 给爸妈用心地做回早餐

如果愿意 你还可以和爸妈说
咱们玩个小游戏吧 ACM课上学的呢~

下面是一个二人小游戏:桌子上有M堆扑克牌;每堆牌的数量分别为Ni(i=1…M);两人轮流进行;每走一步可以任意选择一堆并取走其中的任意张牌;桌子上的扑克全部取光,则游戏结束;最后一次取牌的人为胜者。
现在我们不想研究到底先手为胜还是为负,我只想问大家:
——“先手的人如果想赢,第一步有几种选择呢?”
 
Input
输入数据包含多个测试用例,每个测试用例占2行,首先一行包含一个整数M(1<M<=100),表示扑克牌的堆数,紧接着一行包含M个整数Ni(1<=Ni<=1000000,i=1…M),分别表示M堆扑克的数量。M为0则表示输入数据的结束。
 
Output
如果先手的人能赢,请输出他第一步可行的方案数,否则请输出0,每个实例的输出占一行。
 
Sample Input
3
5 7 9
0
 
Sample Output
1
---------------------
作者:午夜阳光psb
来源:CSDN
原文:https://blog.csdn.net/u013514928/article/details/69055286
版权声明:本文为博主原创文章,转载请附上博文链接!

# include<stdio.h>
int main()
{
    int nPile,i,sum,cnt;
    int p[105];
    while(scanf("%d",&nPile)&&nPile)
    {
        cnt=0;
        sum=0;
        for(i=0;i<nPile;i++)
        {
            scanf("%d",&p[i]);
            sum^= p[i];
        }
        for(i=0;i<nPile;i++)
        {
            if(p[i]>(sum^p[i]))//注意'^'的优先级小于'>'
                cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

  

转载于:https://www.cnblogs.com/mjn1/p/9866877.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Covering version 5 of the Spring Framework, this book is the most comprehensive Spring reference and practical guide available for harnessing the power of this leading enterprise Java application development framework. This edition covers core Spring and its integration with other leading Java technologies, such as Hibernate, JPA 2, Tiles, Thymeleaf, and WebSocket. The focus of the book is on using Java configuration classes, lambda expressions, Spring Boot, and reactive programming. We share our insights and real-world experiences with enterprise application development, including remoting, transactions, the web and presentation tiers, and much more. With Pro Spring 5, you’ll learn how to do the following: • Use inversion of control (IoC) and dependency injection (DI) • Discover what’s new in Spring Framework 5 • Build Spring-based web applications using Spring MVC and WebSocket • Build Spring web reactive applications with Spring WebFlux • Test Spring applications using Junit 5 • Utilize the new Java 8 lambda syntax • Use Spring Boot to an advanced level to get any kind of Spring application up and running in no time • Use Java 9 features in Spring applications Because the Java 9 release date kept being postponed, Spring 5 was released based on Java 8. Thus, interoperability with Java 9 is covered in this book based on an early-access build. There is a multimodule project associated with this book, configured using Gradle 4. The project is available on the Apress official repository: https://github.com/Apress/pro-spring-5. The project can be built right after cloning according to the instructions in its README.adoc file as long as Gradle is installed locally. If you do not have Gradle installed, you can rely on InteliJ IDEA to download it and use it to build your project by using the Gradle Wrapper. (https://docs.gradle.org/current/userguide/ gradle_wrapper.html). There is a small appendix at the end of the book describing the project structure, configuration and

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值