当前位置:网站首页>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;
}
边栏推荐
- linux下centos7中mysql5.7安装教程
- leetcode MYSQL数据库题目177
- Caused by: org. apache. xerces. impl. io. MalformedByteSequenceException: Invalid byte 3 of 3-byte UTF-8
- Hystrix熔断器:服务熔断与服务降级
- 2019.11.17训练总结
- 请用已学过的知识编写程序,找出小甲鱼藏在下边这个长字符串中的密码,密码的埋藏点符合以下规律:
- 内网穿透工具frp使用入门
- Perfect binary tree, complete binary tree, perfect binary tree
- GSOAP example - calc
- Pointer functions and function pointers
猜你喜欢

自定义mvc框架实现

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

力扣94二叉树的中序遍历

A 2.5D Cancer Segmentation for MRI Images Based on U-Net

图片验证码控件

Gross Tumor Volume Segmentation for Head and Neck Cancer Radiotherapy using Deep Dense Multi-modalit

Gmail: how to quickly read all messages

Middle order traversal of Li Kou 94 binary tree

Listview of the basic component of the shutter

Gmail:如何快速将邮件全部已读
随机推荐
Flutter 基础组件之 GridView
Sublime Text3 set to run your own makefile
Gmail: how to quickly read all messages
Gmail:如何快速将邮件全部已读
TLAB of JVM
Leetcode MySQL database topic 181
2019.11.20训练总结
RecyclerView 粘性(悬浮)头部
C # judge whether the array contains any items of another array
2019-11-10训练总结
Generic paging framework
Idea debugging fails, reporting jdwp no transports initialized, jvmtierror=agent_ ERROR_ TRANSPORT_ LOAD(196)
manacher
2020-09-17 gateway业务流程 两个任务:referer认证和非商品模板化
JVM之 MinorGC、 MajorGC、 FullGC、
指针函数和函数指针
2019.11.3学习总结
mysql修改自动递增初始值
GSOAP example - calc
监控数据源连接池使用情况