Stone

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 179    Accepted Submission(s): 137

Problem Description
Tang and Jiang are good friends. To decide whose treat it is for dinner, they are playing a game. Specifically, Tang and Jiang will alternatively write numbers (integers) on a white board. Tang writes first, then Jiang, then again Tang, etc... Moreover, assuming that the number written in the previous round is X, the next person who plays should write a number Y such that 1 <= Y - X <= k. The person who writes a number no smaller than N first will lose the game. Note that in the first round, Tang can write a number only within range [1, k] (both inclusive). You can assume that Tang and Jiang will always be playing optimally, as they are both very smart students.
 
Input
There are multiple test cases. For each test case, there will be one line of input having two integers N (0 < N <= 10^8) and k (0 < k <= 100). Input terminates when both N and k are zero.
 
Output
For each case, print the winner's name in a single line.
 
Sample Input
1 1
30 3
10 2
0 0
 
Sample Output
Jiang
Tang
Jiang
 
Source
 
Recommend
liuyiding
 

很水的博弈,和取石子游戏是一样的。

必败点是 (n-1)%(k+1)==0

  1. /* ***********************************************
  2. Author :kuangbin
  3. Created Time :2013/9/28 星期六 12:09:01
  4. File Name :2013长春网络赛\1006.cpp
  5. ************************************************ */
  6.  
  7. #pragma comment(linker, "/STACK:1024000000,1024000000")
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <iostream>
  11. #include <algorithm>
  12. #include <vector>
  13. #include <queue>
  14. #include <set>
  15. #include <map>
  16. #include <string>
  17. #include <math.h>
  18. #include <stdlib.h>
  19. #include <time.h>
  20. using namespace std;
  21.  
  22. int n,k;
  23. int main()
  24. {
  25. //freopen("in.txt","r",stdin);
  26. //freopen("out.txt","w",stdout);
  27. while(scanf("%d%d",&n,&k) == )
  28. {
  29. if(n == && k == )break;
  30. if((n-)%(k+) == )printf("Jiang\n");
  31. else printf("Tang\n");
  32. }
  33. return ;
  34. }

HDU 4764 Stone (2013长春网络赛,水博弈)的更多相关文章

  1. HDU 4768 Flyer (2013长春网络赛1010题,二分)

    Flyer Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  2. HDU 4763 Theme Section (2013长春网络赛1005,KMP)

    Theme Section Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  3. HDU 4762 Cut the Cake (2013长春网络赛1004题,公式题)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  4. HDU 4759 Poker Shuffle(2013长春网络赛1001题)

    Poker Shuffle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  5. hdu 5438 Ponds(长春网络赛 拓扑+bfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5438 Ponds Time Limit: 1500/1000 MS (Java/Others)     ...

  6. hdu 5441 (2015长春网络赛E题 带权并查集 )

    n个结点,m条边,权值是 从u到v所花的时间 ,每次询问会给一个时间,权值比 询问值小的边就可以走 从u到v 和从v到u算不同的两次 输出有多少种不同的走法(大概是这个意思吧)先把边的权值 从小到大排 ...

  7. hdu 4813(2013长春现场赛A题)

    把一个字符串分成N个字符串 每个字符串长度为m Sample Input12 5 // n mklmbbileay Sample Outputklmbbileay # include <iost ...

  8. HDU 4730 We Love MOE Girls (2013成都网络赛,签到水题)

    We Love MOE Girls Time Limit: 1000/500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  9. 2012年长春网络赛(hdu命题)

    为迎接9月14号hdu命题的长春网络赛 ACM弱校的弱菜,苦逼的在机房(感谢有你)呻吟几声: 1.对于本次网络赛,本校一共6名正式队员,训练靠的是完全的自主学习意识 2.对于网络赛的群殴模式,想竞争现 ...

随机推荐

  1. 如何使用 grunt

    1>. 首先要有nodejs环境, 至少0.8.0版本: 2>. 转到 项目文件夹下: >npm install –g grunt-cli >npm init #生成一个基本的 ...

  2. Zookeeper集群 + Kafka集群 + KafkaOffsetMonitor 监控

    一.Zookeeper ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件.它是一个为分布式应用提供一 ...

  3. Anaconda+django写出第一个web app(十)

    今天继续学习外键的使用. 当我们有了category.series和很多tutorials时,我们查看某个tutorial,可能需要这样的路径http://127.0.0.1:8000/categor ...

  4. CSS absolute与relative不得不说的故事

    写在开篇: absolute说:“relative,我这辈子都不想看见你!” 为什么呢?它们明明那么相亲相爱,形影不离,这之中到底发生了什么不为人知的故事,竟然让absolute如此讨厌relativ ...

  5. Windows运行命令

    winver---------检查Windows版本 wmimgmt.msc----打开windows管理体系结构 wupdmgr--------windows更新程序 winver--------- ...

  6. Linux信号(signal)机制【转】

    转自:http://gityuan.com/2015/12/20/signal/ 信号(signal)是一种软中断,信号机制是进程间通信的一种方式,采用异步通信方式 一.信号类型 Linux系统共定义 ...

  7. 【Hadoop】搭建完全分布式的hadoop【转】

    转自:http://www.cnblogs.com/laov/p/3421479.html 下面博文已更新,请移步 ↑ 用于测试,我用4台虚拟机搭建成了hadoop结构 我用了两个台式机.一个xp系统 ...

  8. org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from URL

    [报错] org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XM ...

  9. java.util.concurrent.RejectedExecutionException

    java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@59f1ca76 rejec ...

  10. Python常见面试(习题)——水仙花数

    今天,给大家分享一个习题. 用python输出100到1000以内的水仙花数. 相信很多小伙伴都听到过,或者遇到过这个题目. 那么今天就来带大家做一做这道题. 首先,我们要知道什么是水仙花数, (@_ ...