Be the Winner( HDU2509)Nim博弈

Problem Description
Let's consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time.
For example "@@@" can be turned into "@@" or "@" or "@ @"(two piles). two people get apples one after another and the one who takes the last is
the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
 

Input
You will be given several cases. Each test case begins with a single number n (1 <= n <= 100), followed by a line with n numbers, the number of apples in each pile. There is a blank line between cases.
 

Output
If a winning strategies can be found, print a single line with "Yes", otherwise print "No".
 

Sample Input
  
  
2 2 2 1 3
 

Sample Output
  
  
No Yes
思路:
最后取光者负,则要考虑全为1的情况,为Nim博弈的变形
 
代码:
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int ans=0,flag=1;
		int a;
		for(int i=0;i<n;i++){
			scanf("%d",&a);
			if(a!=1) flag=0;
			ans^=a;
		}
		if(!flag){
			if(ans) printf("Yes\n");
		    else printf("No\n");
		}
		else{
			if(n%2) printf("No\n");
			else printf("Yes\n");
		}
	}
	return 0;
} 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
通达信winner算法是一种常用的股票投资策略,它主要是通过技术指标来辅助股票投资的决策。这个算法根据股票的价格走势和成交量等指标,结合一定的计算公式和规则,来判断股票的买入卖出时机。 通达信winner算法的核心思想是追踪股票的走势,以最佳时机买入卖出股票。具体来说,该算法会根据股票的价格和成交量波动进行计算,从中筛选出表现较好的股票,并根据不同的买入卖出规则来制定投资策略。 这个算法主要使用了一些常见的技术指标,例如移动平均线、相对强弱指标等,通过这些指标的综合计算,可以得出一个反映股票走势的指标数值。投资者可以根据这些指标的数值来判断股票的走势和可能的涨跌情况,从而制定相应的投资策略。 通达信winner算法并不是一种绝对准确的预测方法,它只是一种参考工具,可以帮助投资者更好地了解股票市场的行情,提供一些参考信息。投资者在使用这个算法时,还需要结合其他分析方法和自己的判断力来进行投资决策。 总的来说,通达信winner算法是一种辅助股票投资决策的技术指标计算方法,该算法通过综合计算股票的价格和成交量等指标来判断股票走势,帮助投资者制定买入卖出策略。但是投资者在使用时需要注意,该算法只是一种参考工具,投资决策还需要结合其他分析方法和个人判断来进行。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值