E - Coin Game
After hh has learned how to play Nim game, he begins to try another coin game which seems much easier.
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.
Input
The first line is a number T(1<=T<=100), represents the number of case. The next T blocks follow each indicates a case.
Each case contains two integers N(3<=N<=10 9,1<=K<=10).
Output
For each case, output the number of case and the winner "first" or "second".(as shown in the sample output)
Sample Input
2
3 1
3 2
Sample Output
Case 1: first
Case 2: second
k=1的时候,看数量,
如果n<=k,a赢
一个环形博弈,可以拆成两条一样的线,然后后者跟着前者拿就可以了,所以后方一定会赢
E - Coin Game的更多相关文章
- [LeetCode] Coin Change 硬币找零
You are given coins of different denominations and a total amount of money amount. Write a function ...
- 洛谷P2964 [USACO09NOV]硬币的游戏A Coin Game
题目描述 Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game c ...
- [luogu2964][USACO09NOV][硬币的游戏A Coin Game] (博弈+动态规划)
题目描述 Farmer John's cows like to play coin games so FJ has invented with a new two-player coin game c ...
- LeetCode Coin Change
原题链接在这里:https://leetcode.com/problems/coin-change/ 题目: You are given coins of different denomination ...
- ACM Coin Test
Coin Test 时间限制:3000 ms | 内存限制:65535 KB 难度:1 描述 As is known to all,if you throw a coin up and let ...
- HDOJ 2069 Coin Change(母函数)
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- leetcode:Coin Change
You are given coins of different denominations and a total amount of money amount. Write a function ...
- UVa 674 Coin Change【记忆化搜索】
题意:给出1,5,10,25,50五种硬币,再给出n,问有多少种不同的方案能够凑齐n 自己写的时候写出来方案数老是更少(用的一维的) 后来搜题解发现,要用二维的来写 http://blog.csdn. ...
- Epic - Coin Change
Something cost $10.25 and the customer pays with a $20 bill, the program will print out the most eff ...
- UVA 674 Coin Change (DP)
Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make c ...
随机推荐
- eclipse-在编译项目时js特别慢的问题
eclipse在编译项目时,当项目中导入了很多第三方js库时,eclipse在验证js时会消耗大量的时间,而我们却完全不用考虑那些js是否有错误 步骤: 去除eclipse的JS验证: 1.将wind ...
- hive 字段名称显示
首先查看一个sql 1.首先存在一个数据表tmp CREATE TABLE tmp( platform string, channel string, chan_value string, uid s ...
- oracle访问不同用户的表不添加用户名前缀
问题的出现,是技术的不断推进.为了更好地实现价值的提升! 01.用视图 create view tab1 select * from B.tab1; //在A用户下执行 02.同义词 gr ...
- 基于CentOS搭建Nginx 静态网站
系统要求: CentOS 7.2 64 位操作系统 一. 安装 Nginx(在 CentOS 上,可直接使用 yum 来安装 Nginx) yum install nginx -y 安装完成后,使用 ...
- arcgis server瓦片行列号计算
2013-08-01 arcgis server切图时会设置一个原点坐标,如果是经纬度坐标一般默认(x0,y0)=(-400,400)作为切图的起始点,即从这开始算行列号.假设切图的地图某点坐标为x, ...
- SNF快速开发平台MVC-表格单元格合并组件
1. 表格单元格合并组件 1.1. 效果展示 1.1.1. 页面展现表格合并单元格 图 4.1 1.1.2. 导出excel合并单元格 图 4.2 1.2. 调用说 ...
- 完美的代码生成器SNF.CodeGenerator-快速开发者的利器--SNF快速开发平台3.1
第1章 SNF.CodeGenerator代码生成器简介 本项目是完全基于Spring.Net.Framework 平台进行研发.与Spring.Net.Framework平台无缝衔接.并支持模型层. ...
- mysql8.0.11修改root密码,其他创建用户和删除用户
1.7. 查询用户密码: 查询用户密码命令:mysql> select host,user,authentication_string from mysql.user; host: 允许用户登录 ...
- 远程桌面中Tab键不能补全的解决办法
我们曾在之前的一篇文章中介绍了windows远程连接ubuntu的方法,在成功登陆远程桌面环境之后,发现在终端中Tab键不能自动补齐(但是Ctrl +Tab 可以用,但是需要按下组合键才能补全的话,时 ...
- 【emWin】例程十五:触摸校准实例——五点校准法
介绍: 该例程介绍如何校准4.3寸.7寸液晶显示屏.校准方法如下: 1.进入以下界面,用户可选择是否进入校准界面进行液晶校准 *点击屏幕任何地方可进入校准界面 *不采取任何操作,几秒钟后会进入触摸测试 ...