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的更多相关文章

  1. [LeetCode] Coin Change 硬币找零

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  2. 洛谷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 ...

  3. [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 ...

  4. LeetCode Coin Change

    原题链接在这里:https://leetcode.com/problems/coin-change/ 题目: You are given coins of different denomination ...

  5. ACM Coin Test

    Coin Test 时间限制:3000 ms  |  内存限制:65535 KB 难度:1   描述 As is known to all,if you throw a coin up and let ...

  6. HDOJ 2069 Coin Change(母函数)

    Coin Change Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. leetcode:Coin Change

    You are given coins of different denominations and a total amount of money amount. Write a function ...

  8. UVa 674 Coin Change【记忆化搜索】

    题意:给出1,5,10,25,50五种硬币,再给出n,问有多少种不同的方案能够凑齐n 自己写的时候写出来方案数老是更少(用的一维的) 后来搜题解发现,要用二维的来写 http://blog.csdn. ...

  9. Epic - Coin Change

    Something cost $10.25 and the customer pays with a $20 bill, the program will print out the most eff ...

  10. 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 ...

随机推荐

  1. python3 requests获取某网站折线图上数据

    比如要抓取某网站折线图上数据,如下截图: 借助Chrome开发者工具Network.经过分析发现获取上面的热度数据,找到对应的事件url:https://pcw-api.iqiyi.com/video ...

  2. .NET 同步与异步 之 原子操作和自旋锁(Interlocked、SpinLock)(九)

    本随笔续接:.NET 同步与异步之锁(ReaderWriterLockSlim)(八) 之前的随笔已经说过.加锁虽然能很好的解决竞争条件,但也带来了负面影响:性能方面的负面影响.那有没有更好的解决方案 ...

  3. 使用ExpandableListView以及如何优化view的显示减少内存占用

    上篇博客讲到如何获取手机中所有歌曲的信息.本文就把上篇获取到的歌曲按照歌手名字分类.用一个ExpandableListView显示出来. MainActivity .java   public cla ...

  4. SNF快速开发平台MVC-EasyQuery-拖拽生成SQL脚本

    在之前介绍一下EasyQuery工具SNF开发平台WinForm-EasyQuery统计分析-效果-非常牛逼的报表查询工具 Winform开发框架之图表报表在线设计器-报表-SNF.EasyQuery ...

  5. Apache Spark 2.3.0 正式发布

    本章内容: 待整理 参考文献: Spark Release 2.3.0

  6. 第三部分:Android 应用程序接口指南---第二节:UI---第九章 搜索

    第9章 搜索 在android平台上搜索是一个核心的用户功能.无论内容位于设备或网络上,用户应该能够搜索任何对它们可用的数据.为了创建一个一致的用户搜索体验,Android平台提供了一个搜索框架帮助你 ...

  7. [svc]mysql备份恢复及常用命令

    如何实现mysql读写分离 1.通过程序实现读写分类(性能 效率最佳) php和java都可以通过设置多个连接文件轻松实现对db的读写分离,即当select时,就去连读库的连接文件,当update,i ...

  8. Python--Redis实战:第四章:数据安全与性能保障:第7节:非事务型流水线

    之前章节首次介绍multi和exec的时候讨论过它们的”事务“性质:被multi和exec包裹的命令在执行时不会被其他客户端打扰.而使用事务的其中一个好处就是底层的客户端会通过使用流水线来提高事务执行 ...

  9. 项目在iOS11上遇到的小问题

    ​iOS11正式版出了这么久了,在忙完新版本开发,写下在iOS11上的一些小问题. 1  App图标不显示 现象:升级到iOS11系统下自己的项目桌面app图标不见了 出现这种情况我还以为自己手动删除 ...

  10. jsonp的工作原理

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...