当前位置:网站首页>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;
}
边栏推荐
- ThinkPHP+Redis实现简单抽奖
- 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
- 2022 cable crane driver examination registration and cable crane driver certificate examination
- What operations need attention in the spot gold investment market?
- Is there anything in common between spot gold and spot silver
- 【第29天】给定一个整数,请你求出它的因子数
- Basis of information entropy
- Trois tâches principales: asynchrone, courrier et timing
- Database SQL language 02 connection query
- On Fibonacci sequence
猜你喜欢

异步、郵件、定時三大任務

MySQL - database query - basic query

MySQL --- 数据库查询 - 条件查询
![[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge](/img/ed/23331d939c9338760e426d368bfd5f.png)
[my advanced journey of OpenGL learning] collation of Euler angle, rotation order, rotation matrix, quaternion and other knowledge

Dotconnect for PostgreSQL data provider
![[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)](/img/ca/1d2473ae51c59b84864352eb17de94.jpg)
[flutter] icons component (fluttericon Download Icon | customize SVG icon to generate TTF font file | use the downloaded TTF icon file)

【我的OpenGL学习进阶之旅】关于欧拉角、旋转顺序、旋转矩阵、四元数等知识的整理

Telephone network problems
![[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core](/img/fb/c371ffaa9614c6f2fd581ba89eb2ab.png)
[FPGA tutorial case 6] design and implementation of dual port RAM based on vivado core

Basic remote connection tool xshell
随机推荐
Machine learning terminology
Telephone network problems
MySQL
Excel removes the data after the decimal point and rounds the number
机器学习术语
[androd] module dependency replacement of gradle's usage skills
uniapp组件-uni-notice-bar通告栏
MySQL basics 03 introduction to MySQL types
Makefile中wildcard、patsubst、notdir的含义
Draw love with go+ to express love to her beloved
Kivy tutorial how to create drop-down lists in Kivy
Test shift right: Elk practice of online quality monitoring
Arduino DY-SV17F自动语音播报
The latest analysis of tool fitter (technician) in 2022 and the test questions and analysis of tool fitter (technician)
Merge K sorted linked lists
力扣 204. 计数质数
Kivy教程大全之如何在 Kivy 中创建下拉列表
How is the mask effect achieved in the LPL ban/pick selection stage?
基本远程连接工具Xshell
产业互联网的产业范畴足够大 消费互联网时代仅是一个局限在互联网行业的存在