当前位置:网站首页>The Stones Game【取石子博弈 & 思维】
The Stones Game【取石子博弈 & 思维】
2022-06-29 09:18:00 【是Mally呀!】
The Stones Game【取石子博弈 & 思维】
注
2020.7.22补题
Problem G. The Stones Game

题意
有n个石头,m个选手
每个选手要做2步操作:
(1)拿一块石头或者不拿
(2)如果上一个选手的操作(1)是拿了石头 或者当前选手是1号选手,那么这一步不可以拿石头,反之,必须拿石头。
" if this is not the first turn and in the previous turn the player decided not to remove a stonein his/her first step, then the current player must remove a stone in this step" 这句话很难理解~,把它变成否定句,and变成or,就可以得到上面的那句话。
谁最后取完石头睡赢,问n个石头,m个选手下,y是否处于必赢态。
分析
1号选手第(1)步拿了石头,(2)步不能拿石头,那么2号选手第(1)步可以选择拿和不拿,第(2)步不能拿。
因此2个选手最少要拿1个石头,最多拿2个石头、
如果是有3个选手,也可以推得最多拿3个,最少拿2个。
因此如果有3个选手,要拿3个石头,那么3号选手是必赢态。
有n个石头,m个选手时,n%m号选手是必赢态。
#include "bits/stdc++.h"
using namespace std;
int main()
{
int cas;
scanf("%d",&cas);
while (cas--)
{
int n,m,y;
scanf("%d %d %d",&n,&m,&y);
int k=n%m;
if(k==0)k=m;
if(y==k)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
边栏推荐
- Rikka with Cake(线段树+线段树)
- GCC and makefile
- LiferayPortal JSONWS反序列化漏洞(CVE-2020-7961)分析
- ORA-01950 对表空间无权限
- The 23 most useful elasticsearch search techniques you must know
- 2019icpc上海区域赛赛后总结
- Zabbix4.4 configure the indicators of the monitoring server and solve the garbled graphics pages
- cenos7下搭建LAMP环境
- RecyclerView刷新闪烁与删除Item时崩溃问题
- 安装Anaconda后启动JupyterLab需要输入密码
猜你喜欢

C语言实现一种创建易管理易维护线程的方法

自定义控件之侧滑关闭 Activity 控件

JVM之对象的内存布局

Cisco ASA、FTD和HyperFlex HX的漏洞分析复现

JVM之方法的绑定机制

Install and configure redis in the Linux environment, and set the boot auto start

Automatic Multi-Organ SegmVentation on Abdominal CT With Dense V-Networks

Fully Automated Gross Tumor Volume Delineation From PET in Head and Neck Cancer Using Deep Learning

A 3D Dual Path U-Net of Cancer Segmentation Based on MRI

完美二叉树、完全二叉树、完满二叉树
随机推荐
Force deduction 85 question maximum rectangle
Flutter 基础组件之 Container
GSOAP example - calc
容器
Automatic Multi-Organ SegmVentation on Abdominal CT With Dense V-Networks
Monitoring data source connection pool usage
Install and configure redis in the Linux environment, and set the boot auto start
Gmail: how to quickly read all messages
gSoap例子——calc
阿里云防火墙配置,多种设置方式(iptables和fireward)
滑块验证代码
監控數據源連接池使用情况
C # judge whether the array contains any items of another array
Gross Tumor Volume Segmentation for Head and Neck Cancer Radiotherapy using Deep Dense Multi-modalit
通用分页框架
Leetcode MySQL database topic 181
Mysql5.7 installation tutorial in centos7 under Linux
LiferayPortal JSONWS反序列化漏洞(CVE-2020-7961)分析
2019.11.3学习总结
Sublime Text3 set to run your own makefile