当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

自定义控件之下载控件1(DownloadView1)

KDevelop new project

Application of decorator mode, packaging ServletRequest and adding addparameter method

JVM之方法返回地址

弧形 View 和弧形 ViewPager

float 与 int 相乘产生的令人崩溃的“ 2.3 * 10 = 22 ”

Flutter 基础组件之 GridView

Dynamic linking of virtual machine stack of JVM

Middle order traversal of Li Kou 94 binary tree

Gmail: how to quickly read all messages
随机推荐
C语言中通过sprintf()函数构造sql语句
内网穿透工具frp使用入门
kdevelop新建工程
JVM之方法返回地址
JS obtain mobile phone model and system version
linux环境下安装配置redis,并设置开机自启动
2020-09-21 referer字符串切分 boost gateway代码组织层次
Community Union
Setinterval, setTimeout and requestanimationframe
C语言实现一种创建易管理易维护线程的方法
The collapsing "2.3 * 10 = 22" produced by multiplying float and int
微信小程序实现store功能
阿里云服务器安装配置redis,无法远程访问
A 2.5D Cancer Segmentation for MRI Images Based on U-Net
PHP内存马技术研究与查杀方法总结
After installing anaconda, you need to enter a password to start jupyterlab
MySQL modify auto increment initial value
JVM instructions for four call methods
2020-09-17 gateway业务流程 两个任务:referer认证和非商品模板化
XML布局中Button总是在最上层显示