HDU 3951 Coin Game (简单博弈)
Coin Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 888 Accepted Submission(s): 547

The game goes like this:
Two players start the game with a circle of n coins.
They take coins from the circle in turn and every time they could take 1~K continuous coins.
(imagining that ten coins numbered from 1 to 10 and K equal to 3, since 1 and 10 are continuous, you could take away the continuous 10 , 1 , 2 , but if 2 was taken away, you couldn't take 1, 3, 4, because 1 and 3 aren't continuous)
The player who takes the last coin wins the game.
Suppose that those two players always take the best moves and never make mistakes.
Your job is to find out who will definitely win the game.
Each case contains two integers N(3<=N<=109,1<=K<=10).
3 1
3 2
Case 2: second
题意:有一圈n个的硬币, 两个玩家轮流取,每次他们可以取1 ~ K个连续硬币, 最后一个取完为胜;
思路: 面对一个可以一次拿完的局面先手必胜, 如果k=1 那么由N的奇偶性决定, 否则后手一定可以使下一个局面为对称的, 因此一定会赢;
#include<iostream>
#include<cstdio>
#include<cstring> using namespace std; int main(){ //freopen("input.txt","r",stdin); int t,cases=;
scanf("%d",&t);
int n,k;
while(t--){
scanf("%d%d",&n,&k);
printf("Case %d: ",++cases);
if(k>=n){
puts("first");
continue;
}
if(k==){
if(n&)
puts("first");
else
puts("second");
}else //当k>=2时,后手一定可以使下一个局面为对称的, 因此一定会赢
puts("second");
}
return ;
}
HDU 3951 Coin Game (简单博弈)的更多相关文章
- HDU 1079 Calendar Game(简单博弈)
Calendar Game Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- hdu 1846 Brave Game 简单博弈
Problem Description 十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫<勇敢者的游戏>(英文名称:Zathura),一直到现在,我依然对于电影中 ...
- hdu 3951 - Coin Game(找规律)
这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...
- hdu 3951 Coin Game 博弈论
思路: 当n<=k时,先手必胜: 当k=1时,n为奇数先手胜,否则后手胜: 当k>1时,先手操作之后必定形成链,后手操作后形成二条一样的链,之后,先手怎么操作,后手就怎么操作,则后手必胜. ...
- hdu 2149 Public Sale 简单博弈
Problem Description 虽然不想,但是现实总归是现实,Lele始终没有逃过退学的命运,因为他没有拿到奖学金.现在等待他的,就是像FarmJohn一样的农田生涯.要种田得有田才行,Lel ...
- HDU 1564 简单博弈 水
n*n棋盘,初始左上角有一个石头,每次放只能在相邻的四个位置之一,不能操作者输. 如果以初始石头编号为1作为后手,那么对于每次先手胜的情况其最后一步的四周的编号必定是奇数,且此时编号为偶数,而对于一个 ...
- ACM: NBUT 1107 盒子游戏 - 简单博弈
NBUT 1107 盒子游戏 Time Limit:1000MS Memory Limit:65535KB 64bit IO Format: Practice Appoint ...
- HDU 1524 树上无环博弈 暴力SG
一个拓扑结构的图,给定n个棋的位置,每次可以沿边走,不能操作者输. 已经给出了拓扑图了,对于每个棋子找一遍SG最后SG和就行了. /** @Date : 2017-10-13 20:08:45 * @ ...
- 取石子游戏 HDU 1527 博弈论 威佐夫博弈
取石子游戏 HDU 1527 博弈论 威佐夫博弈 题意 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两 ...
随机推荐
- Spring(十一):Spring配置Bean(四)SpEL
Spring表达式语言:SpEL 1)Spring表达式语言(简称SpEL):是一个支持运行时查询和操作对象图的强大的表达式语言. 2)语法类似于EL:SpEL使用#{...}作为界定符,所有在大框号 ...
- 原:wireshare使用技巧收集
/data/local/tcpdump -p -vv -s 0 -w /sdcard/ThinkDrive.pcap 先抓一个pcap的包. 1. 查看所有的链接与流量 统计->对话 这 ...
- php manager
https://phpmanager.codeplex.com/releases/view/69115
- MySQL8.0手动安装心得。
https://dev.mysql.com/downloads/mysql/ mysql从5.7一下子跳跃到了8.0,其中的改变还是很大,有点这里就不说了,小伙伴们自己去百度了解一下,这里重点说一下, ...
- 使用Robot Framework做接口测试
http://chuansong.me/n/1858477 1.RF框架 1.1 RF框架介绍Robot Framework 框架是一个通用的测试框架,一直是由诺西网络(Nokia Siemens N ...
- 【Python】使用torrentParser1.02对多文件torrent的分析结果
C:\Users\horn1\Desktop\python\41-torrentParser>python torrentParser.py 文件名=./6.torrent 文件结构: anno ...
- 编码GBK的不可映射字符
1.错误描写叙述 [ERROR] /E:/Eclipse/workspace/huxs/src/test/java/com/you/huxs/utils/SpringTestBase.java:[14 ...
- Android 基本 Jackson Marshalling(serialize)/Unmarshalling(deserialize)
本文内容 基本 Jack Marshalling 忽略属性 忽略 Null 字段 改变字段名字 基本 Jackson Marshalling 把 JSON 解析成 JsonNode Unmarshal ...
- Office办公 WPS如何设置页边距
打开页眉页脚,在选项里面可以设置顶部的一行文字距离边界的距离 此外在页面布局,页边距也可以查看和修改
- Centos7中firewalld防火锁墙的使用
一.服务控制 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disable firewal ...