hdu2509 Be the Winner (反尼姆博弈 )

article/2025/11/2 17:04:00

hdu2509 Be the Winner

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

Source
ECJTU 2008 Autumn Contest

题解: 根据题意最后取完的人失败,可以看出这是一题反尼姆博弈,也是模板题。

我们可以参考这张图片理解反尼姆博弈。
在这里插入图片描述
根据这张图片我们可以进行总结。令ans为所有堆的异或和,cnt为充裕堆的数量。由上述可知T0,S1,S2状态下先手必胜。
T0:ans==0 && cnt == 0;
S1:ans!=0 && cnt == 1;
S2:ans!=0 && cnt >= 2;
由上可知当先手必胜时 ** ans == 0 && cnt == 0 || ans != 0 && cnt! =0 **

#include<list>
#include<string.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e4 + 10;
const int inf = 0x3f3f3f3f;
const int Base =131;
const ll INF = 1ll << 62;
//const double PI = acos(-1);
const double eps = 1e-7;
const int mod = 1e9+7;
#define speed {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); }int main()
{int n;while(~scanf("%d",&n)){	int ans=0,cnt=0,x;for(int i=0;i<n;i++){scanf("%d",&x);ans^=x;if(x>1)cnt++;}if(ans==0&&cnt==0||ans!=0&&cnt!=0)printf("Yes\n");else printf("No\n");}system("pause");return 0;
}

http://chatgpt.dhexx.cn/article/6TNY1sZP.shtml

相关文章

本地win10安装的MySQL8.0.12用navicat12报错 2509 -Authentication plugin ' caching_sha2_password' cannot be :

本地安装了MySQL8.0.12用navicatl 12报错了&#xff0c;报错请款如下: 网上很多的方法都是说在my.ini 文件中添加 default_authentication_pluginmysql_native_password&#xff1b; 我知道有的人的是可以的&#xff0c;但是我的报错 然后有需要修改my.ini文件 最后一行加上…

学习MySQL的第二天,安装MySQL的远程连接工具与解决2509的报错

1&#xff0c;下载并安装MySQL的远程连接工具 安装MySQL远程连接工具结果都一样哈&#xff0c;都是为了方便快捷&#xff0c;点击下方连接从“sqlyogcommunity官网”来下载安装。 https://github.com/webyog/sqlyog-community/wiki/Downloads 下载完后就可以来安装了&#xff…

nivicat破解包安装以及问题解决。MySQL安装版本Navicat连接报错2509解决方案

nivicat安装步骤 https://blog.csdn.net/yhflyl/article/details/95779920。 安装之后出现两个问题&#xff1a; 如图所示&#xff1a;网上查询过后&#xff0c;发现这个错误出现的原因是在mysql8之前的版本中加密规则为mysql_native_password&#xff0c;而在mysql8以后的加…

MySQL安装版本Navicat连接报错2509解决方案

MySQL安装版本Navicat连接报错2509解决方案 【问题产生】 新安装后打开数据库连接报错 【产生原因】 由于新版本的MySQL新特性导致的。 mysql> select Host,User,plugin from mysql.user; ------------------------------------------------- | Host | User | plugin | --…

Windows无法连接到Group Policy Client服务

Citrix XenApp服务器通过PVS启动后&#xff0c;用户访问出现如下的报错&#xff1a; 此报错是由于该Windows服务器的 Group Policy服务没有启动导致的&#xff0c;可以直接登录到该服务器开启Group Policy的服务即可。 但是如果你有好多好多的服务器&#xff0c;你也不知道哪个…

Circumventing Group Policy Settings

Group policy settings are an integral part of any Windows-based IT environment. If you’re a network administrator you use them to enforce corporate security and desktop management policy, and if you’re a user you’ve almost certainly been frustrated by t…

GPP(Group Policy Preferences)策略组首选项漏洞

概念 组策略是配配置计算机中某一些用户组策略的程序 SYSVOL是AD(活动目录)里面一个存储域公共文件服务器副本的共享文件夹&#xff0c;所有域内主机都能访问&#xff0c;里面保存组策略相关数据&#xff0c;包含登录脚本配置文件等 dir /s /a \\域控IP\SYSVOL\*.xml GPO是组策…

Group Policy Client解决方法

最近我同学的电脑遇到了这样的一个问题&#xff1a; 在开机登录界面时无法进入&#xff0c;提示Group Policy Client服务未能登录 其实在开始我也没遇到这样的问题&#xff0c;上网查了很久的资料&#xff0c;最后终于让我给解决了&#xff0c;呵呵…… 现在我就把我的解决方…

windows无法连接到group policy client服务.此问题阻止标准用户登陆系统.

问题描述如图&#xff1a; 解决&#xff1a; 1.winR 输入 regedit,打开注册表编辑器 2.对上图区域右键->权限 3.选定你的用户&#xff0c;点添加->高级->立即查找 4.找到SYSTEM&#xff0c;点击确定 5.然后注册框中出现&#xff0c;点确定&#xff0c;然后重启&#…

Powershell如何修改组策略(group policy)

上一篇&#xff0c;田总手把手给指导了如何实现多跳&#xff0c;手动实现的&#xff0c;没有问题。但是机器众多&#xff0c;这一篇我们用命令来实现组策略的修改。 首先&#xff0c;Powershell不是万能的&#xff0c;Powershell是可以获取到域的组策略(GPO)&#xff0c;并且权…

计算机 服务未能登陆,w7电脑开机提示Group Policy Client服务未能登陆的修复方法...

‍ ‍ w7系统是目前比较多用户自己使用的系统&#xff0c;比较普遍&#xff0c;但是出现的故障也比较多&#xff0c;一般都是大家能自己动手解决的。那么w7电脑开机提示Group Policy Client服务未能登陆怎么回事&#xff1f;要怎么处理这个问题&#xff1f;下面小编就以w732位旗…

win7服务器未能登录怎么解决,win7开机提示group policy client服务未能登录拒绝访问怎么办...

‍‍ 有些win7专业版用户在电脑开机的时候提示group policy client服务未能登录拒绝访问&#xff0c;导致无法进入系统开不了机&#xff0c;遇到这种情况该怎么办呢&#xff1f;group policy client服务用于应用由这台计算机的管理员或者其他用户通过组策略组件配置的设置&…

计算机服务 访问拒绝,Win7开机提示group policy client服务未能登录,拒绝访问的解决方法...

我们在使用电脑的过程中&#xff0c;经常会遇到一些小问题&#xff0c;尤其是电脑开机之后的问题最为常见。近期有一位用户遇到电脑开机提示“group policy client服务未能登录,拒绝访问”。那么我们要如何解决这个问题呢&#xff1f;下面装机之家分享一下Win7开机提示group po…

故障:ID1085 的 GroupPolicy 警告日志

1、故障现象: 1)Windows Server 2008 with SP2 的域控制器上,每隔 5 分钟,在 System Log 中出现 ID1085 的 GroupPolicy 警告日志: 2)同时,在 Application Log 中出现 ID8194 的 Group Policy Services 错误日志: 2、故障处理: 1)删除文件夹: C:\ProgramData\Appl…

使用Windows10 group policy关闭Virtualization Security

执行命令msinfo32: 查看system info&#xff0c;发现Virtualization-based security处于running状态&#xff1a; 执行命令行gpedit&#xff0c;打开group policy&#xff1a; 沿下列路径展开&#xff1a; Local Computer Policy > Computer Configuration > Administr…

win10服务器未能登录怎么办,win10系统开机提示Group policy Client服务未能登陆的解决技巧...

有越来越多的用户喜欢win10系统了。在日常的安装和使用过程中&#xff0c;免不了总能碰见win10系统开机提示Group policy Client服务未能登陆的问题。面对突然出现的win10系统开机提示Group policy Client服务未能登陆的问题&#xff0c;对于一些仅仅将电脑作为工具使用的菜鸟来…

Managing Group Policy with PowerShell

Overview In this article, I’ll talk about your options when it comes to managing Group Policy using PowerShell. To be sure, depending upon your needs, Group Policy is nearly a full citizen in the world of PowerShell-based management. I’ll talk about why …

Windows 组策略(Group Policy Object)机制的漏洞分析

Windows 组策略(Group Policy Object)机制的漏洞类大约有60个,专门针对策略更新步骤,允许域环境中的标准用户执行文件系统攻击,进而使恶意用户可以逃避反恶意软件解决方案,绕过安全性强化并可能导致对Windows 2000的严重攻击。组织的网络。这些漏洞会影响任何Windows计算…

policy服务器未能登录,win7电脑提示group policy client服务未能登录的解决方法

我们都清楚电脑使用久了总是会出现各种各样的问题&#xff0c;其中比较常见的就是系统提示了&#xff0c;最近有位win7系统用户使用电脑的过程中&#xff0c;系统总是会提示“group policy client服务未能登录”&#xff0c;用户不知道怎么解决&#xff0c; 我们都清楚电脑使用…

policy服务器未能登陆,开机出现Group Policy Client服务未能登录的解决措施

最近有使用win7系统的用户反映说&#xff0c;自己将电脑开机后&#xff0c;系统无法正常登录&#xff0c;并且出现Group Policy Client 服务未能登录&#xff0c;拒绝访问的提示&#xff0c;这是怎么回事呢&#xff1f;今天U大侠小编就和大家说说开机Group Policy Client 服务未…