Wolfgang Puck is opening a new exclusive restaurant in Las Vegas and is looking for a chef. His nephew Hansel caught him thinking of posting an ad in newspapers. (Note: Wolfgang has heard of “this Internet thingy”, but didn’t find it interesting because one could not spread some Internet on a piece of bread, which is the mere minimum that has to be satisfied for something to be interesting, according to Mr. Puck.)
    Hansel knows what the advantages of the Internet job postings are, but he came up with an even better idea – given the success of various reality TV shows and given the fact that the restaurant is opening in Las Vegas, why not organize a sort of a cook-off tournament that will decide who Mr. Puck will hire?
    The idea basically combines the Iron Chef™ show with the World Series Of Poker™: Every
show m cooks prepare a five-course meal for judges and the best one (according to the said judges) advances to the next round. All candidates are ranked based on the previous experience so, even if the number of the candidates is not divisible by m, some of them can get a “bye” and compete in later rounds. The winner of the final show gets the honour of being the chef in the best Wolfgang Puck’s restaurant ever.

    Hansel realized that even with the byes it might not be possible to hold a tournament with m chefs per show, so he is trying to find out what the best m for the given number of candidates is. If you can just help him by letting him know if he can run a tournament as described with n candidates and m chefs per show and, in the case he can, how many shows he needs, he will be so grateful that he might even convince Mr. Puck to share the Secret Cheesecake Base Recipe with you.
Input
Input file starts with the line containing a single integer t, the number of test cases. Next t lines each contain two integers separated by spaces, n and m (2 ≤ n ≤ 10000, 2 ≤ m ≤ n), where n is the total number of candidates and m is the number of chefs participating in a single TV show.
Output
For each test case print the number of shows that need to be run to get the new chef. In the case that the tournament cannot be run with given n and m, print ‘cannot do this’.
Sample Input
3
3 2
4 3
4 4
Sample Output
2
cannot do this
1

问题链接:UVA11313 Gourmet Games
问题简述:(略)
问题分析
    数学杂题不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA11313 Gourmet Games */#include <bits/stdc++.h>using namespace std;int main()
{int t, n, m, ans;scanf("%d", &t);while(t--) {scanf("%d%d", &n, &m);ans = 0;for(;;) {if(n == m) {ans++;break;} else if(n < m) {ans = -1;break;} else {ans += n / m;n = n / m + n % m;}}if(ans == -1)printf("cannot do this\n");elseprintf("%d\n", ans);}return 0;
}

UVA11313 Gourmet Games【数学】相关推荐

  1. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  2. Competitive Programming专题题解(1)

    Competitive Programming题解 AOAPC I: Beginning Algorithm Contests 题解 CP2-1.1.1 Easy(Ad Hoc Problems) P ...

  3. [转载]一个图形爱好者的书架/白话说学计算机图形学

    1.一个图形爱好者的书架 原文地址:http://blog.csdn.net/nhsoft/archive/2004/06/23/22992.aspx          早几天看到有人把自己在大学四年 ...

  4. 转----一个图形爱好者的书架.-也来介绍一下我的藏书.

    一个图形爱好者的书架.-也来介绍一下我的藏书. 早几天看到有人把自己在大学四年的书列了出来.招来一顿怀疑.我是开发图形程序的.我现在也把我的书列出来.不怕大家怀疑吧.希望能有点启示作用. 绿色的是我看 ...

  5. 一个图形爱好者的书架

    http://www.360doc.com/content/05/1027/13/2198_24643.shtml 一个图形爱好者的书架.-也来介绍一下我的藏书. 早几天看到有人把自己在大学四年的书列 ...

  6. 经典数学问题:Nim游戏

    Nim游戏的数学理论论述 Nim游戏是博弈论中最经典的模型,是组合游戏(Combinatorial Games)的一种,属于"Impartial Combinatorial Games&qu ...

  7. 游戏设计与计算机,RPG游戏设计与实现-数学与计算机系.doc

    RPG游戏设计与实现-数学与计算机系 XX学院 毕业论文(设计) RPG游戏设计与实现 院 系 :数学与计算机系专业(班级):计算机科学与技术专业2班姓名:XXX学号:20084011023指导教师: ...

  8. CV+游戏,美国游戏开发公司 Rockstar Games 寻找优秀动画程序员

    (图来自Rockstar Games 官网,是即将推出的一款游戏封面) 美国知名游戏公司 Rockstar目前正在寻找一名对研究计算机视觉和机器学习感兴趣的动画研发工程师.为角色扮演游戏开发先进的面部 ...

  9. 最近做到的一些有意思的数学题目(博弈,双人玩游戏)

    最近做一些数学题目,感觉挺有意思的整理了一下. 1.北京理工大学2018级3月月赛A题:Ervin and Joker https://vjudge.net/problem/Gym-241030A#a ...

最新文章

  1. [SPOJ-COT]Count on a tree
  2. 全国大学生智能车竞赛双车接力组芯片申请汇总
  3. JdbcTemplate(1)(数据连接池)
  4. Hadoop 故障整理
  5. Mother's Day
  6. 金融业(互联网金融)创新---我的实地考察和见解
  7. U启动安装原版Win7系统教程
  8. 第一章计算机网络概述答案,第一章 计算机网络概述[3]
  9. 使用var声明的变量 和 直接赋值并未声明的变量的区别
  10. scheduledexecutorservice 的使用_java中ThreadPool的介绍和使用
  11. 菜刀php教程,Weevely(php菜刀)工具使用详解
  12. 图片饱和度_做PPT时,文字放在图片上老是看不清,咋办?
  13. sql 单引号_三种数据库的 SQL 注入详解
  14. python——异常except语句用法与引发异常
  15. Ubuntu18.04 如何解决编译objective-c出现undefined reference to objc_get_class
  16. 如何处理计算机显示器故障,电脑显示器常见的故障及解决办法
  17. 去掉串口硬盘的安全删除硬件图标
  18. 中国移动NBIOT卡的几种APN应用场景
  19. 零基础做油管搬运二创项目的正确方式,短视频小白玩家套利的可能
  20. 极速办公如何在Excel中进行条件计数

热门文章

  1. 如何制作一个横版格斗过关游戏 Cocos2d-x 2.0.4
  2. 使用Box2D制作AS3游戏——2.1a版本——Hello World Box2D .
  3. Direct3D Frustum裁剪原理
  4. 观察者模式代码php,PHP 观察者模式的实现代码
  5. Welcome to Apache HBase 介绍一
  6. uniapp全局传值方式总结
  7. 离散数学 第二类斯特林数 小白学习笔记
  8. 数据切片与MapTask并行度
  9. 对于有一定编程基础的学生来说,看下面这个链接的文章比较好
  10. 机器学习之监督学习(五)——集成学习