当前位置:网站首页>Mathematical Knowledge: Steps - Nim Games - Game Theory
Mathematical Knowledge: Steps - Nim Games - Game Theory
2022-07-03 01:26:00 【Luttez! Sale année!】
Titre:AcWing 892. Étapes-NimLe jeu
Maintenant,Il y a un n L'escalier des marches,Il y a plusieurs pierres sur chaque marche,Dont: i Il y en a sur les marches. ai Un caillou(i≥1).
Les deux joueurs alternent,Chaque opération peut prendre plusieurs pierres de n'importe quelle étape et les placer dans l'étape suivante(Je ne peux pas ne pas prendre).
Les pierres qui ont été prises au sol ne peuvent plus être prises,La dernière personne qui n'a pas pu effectuer l'opération est considérée comme un échec.
Si les deux adoptent la meilleure stratégie,Si l'avant - garde doit gagner.
Format d'entrée
La première ligne contient un entier n.
La deuxième ligne contient: n Nombre entier,Dont: i Les entiers représentent i Le nombre de pierres sur les marches ai.
Format de sortie
Si le premier gagne,Alors la sortie Yes.
Sinon,Produits No.
Champ d'application des données
1≤n≤105,
1≤ai≤109
Exemple d'entrée:
3
2 1 3
Exemple de sortie:
Yes
Analyse du sujet:
Cette question est similaire à la précédente
a1^a3^a5…^an!=0Alors le premier gagne
Le premier gagne la stratégie:
Si on prend des marches paires,Mettez ce que vous avez pris sur l'escalier suivant,Les marches impaires restent inchangées.
Si vous prenez des marches impaires,Alors Xor n'est pas0,L'opération le rend Xor0.
Au contraire,Si Xor est0,Alors l'arrière gagne..
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int res=0;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
if(i%2)res^=x;
}
if(res)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return 0;
}
边栏推荐
- [flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)
- C#应用程序界面开发基础——窗体控制(4)——选择类控件
- 攻克哈希的基本概念与实现
- Compare version number
- [androd] module dependency replacement of gradle's usage skills
- leetcode 6103 — 从树中删除边的最小分数
- Soft exam information system project manager_ Real topic over the years_ Wrong question set in the second half of 2019_ Morning comprehensive knowledge question - Senior Information System Project Man
- 【FH-GFSK】FH-GFSK信号分析与盲解调研究
- [fh-gfsk] fh-gfsk signal analysis and blind demodulation research
- leetcode:871. Minimum refueling times [Pat has done before + maximum stacking + greed]
猜你喜欢
12_ Implementation of rolling automatic video playback effect of wechat video number of wechat applet
Cut point of undirected graph
MySQL --- 数据库查询 - 条件查询
Machine learning terminology
强化学习 Q-learning 实例详解
Asynchronous, email and scheduled tasks
Database SQL language 02 connection query
[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)
MySQL basic usage 02
Expérience de recherche d'emploi d'un programmeur difficile
随机推荐
ThinkPHP+Redis实现简单抽奖
d,ldc構建共享庫
【我的OpenGL学习进阶之旅】关于欧拉角、旋转顺序、旋转矩阵、四元数等知识的整理
What operations need attention in the spot gold investment market?
Kivy tutorial - example of using Matplotlib in Kivy app
Draw love with go+ to express love to her beloved
机器学习术语
按鍵精靈打怪學習-多線程後臺坐標識別
MySQL
对非ts/js文件模块进行类型扩充
2022 coal mine gas drainage examination question bank and coal mine gas drainage examination questions and analysis
看疫情之下服装企业如何顺势而为
不登陆或者登录解决oracle数据库账号被锁定。
dotConnect for PostgreSQL数据提供程序
Now that the teenager has returned, the world's fireworks are the most soothing and ordinary people return to work~
Trois tâches principales: asynchrone, courrier et timing
[shutter] animation animation (shutter animation type | the core class of shutter animation)
软考信息系统项目管理师_历年真题_2019下半年错题集_上午综合知识题---软考高级之信息系统项目管理师053
Machine learning terminology
MySQL foundation 06 DDL