编程介的小学生 2019-06-19 10:49 采纳率: 20.5%
浏览 145

丢石头的游戏中的胜负的判断,采用C语言的程序的编写的设计如何才能实现这个胜负的判断的问题的呢

Problem Description
After he has learned how to play Nim game,Mike begins to try another stone game which seems much easier.

The game goes like this:Two players start the game with a pile of n stones.They take stones from the pile in turn and every time they take at least one stone.The one who goes first can take at most n-1 stones for his first move .from then on a player can take at most k times as many stones as his opponent has taken last time.For example,if one player take m stones in his turn,then the other player can taken at most k * m stones next time.The player who takes the last stone 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 contains a integer t,indicating that there are t test cases following. (t<=20).Each test is a line consisting of two integer n and k.(2<=n<=10^8,1<=k<=10^5).

Output
For each test case,output one line starting with“Case N:”,N is the case number. And then,if the first player can ensure a winning ,print the minimum number of stones he should take in his first turn.Otherwise ,print “lose ”.Please note that there is a blank following the colon.

Sample Input
6
16 1
11 1
32 2
34 2
19 3
100000000 100000

Sample Output
Case 1: lose
Case 2: 1
Case 3: 3
Case 4:lose
Case 5: 4
Case 6: 912

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog