Have meal

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

Problem Description
I
have been in school for several years, so I have visited all messes
here. Now I have lost intersts in all of the foods. So when during the
meal time, I don’t know which mess I should go to. So I came up with a
solution.
There are 4 messes in our school, I number them from 0 to
3. Then I says “Big Bing Small Jiang, Point Who Is Who!”, when I say the
first word I point to the mess which is numbered 0, when I say the i-th
(i>1) word I point to the mess whose number is one larger than the
previous one. In case of the number of previous mess is 3, I will point
to 0 again. I will go to the mess which I point to last time. Thus in
this case I will go to the mess which is numbered 3. The following table
explains the course of my solution to this case.
 Word I say Mess id I point to Big 0 Bing 1 Small 2 Jiang 3 Point 0 Who 1 Is 2 Who 3
I
will go to university after several days, I have heard that there are
so many messes in it. So I will apply my solution again. Surpose there
are n messes which are numberd through 0 to n-1, and I will say m words.
When I say the first word I point to the mess which is numbered 0, when
I say the i-th (i>1) word I point to the mess whose number is one
larger than the previous one. In case of the number of previous mess is
n-1, I will point to 0 again. I will go to the mess which I point to
last time. So which mess will I point to?.
It is so time-consuming to count it through manual work. So I want you to write a program to help me. Would you help me?
 
Input
Multi test cases (about 10000), every case contain two integers n and m in a single line.

[Technical Specification]
1<=n, m<=100

 
Output
For each case, output the number of the mess which I should go to.
 
Sample Input
4 3
1 100
 
Sample Output
2
0
 
Source
 
题意:有n个菜(编号0-n-1),现在有一个人点菜,他点菜的规则是念m个单词,然后按照循环顺序数这n个菜,问最后会点到哪个菜??
#include<stdio.h>
#include<iostream>
#include<string.h>
#include <stdlib.h>
#include<math.h>
#include<algorithm>
#include <queue>
using namespace std;
typedef long long LL; int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
int t = m%n;
if(t==) printf("%d\n",n-);
else printf("%d\n",t-);
}
return ;
}

hdu 5158(水题)的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  3. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  4. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  5. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  6. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  7. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  8. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  9. hdu 5038 水题 可是题意坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心  If not all ...

随机推荐

  1. Jforum环境搭建

    前提:搭建好JDK.JRE.Tomcat.数据库 1.之前安装了Navicat Premium,所以直接用这个创建名为jforum的MySQL数据库,默认密码为空,记得设置密码,因为Jforum要用到 ...

  2. 【转载】Unity3D研究院之共享材质的巧妙用法(sharedMaterial效率问题)

    如果你需要修改模型材质的颜色,或者是修改材质Shader的一些属性, 通常情况是用获取模型的Renderer组件,然后获取它的material属性. 举个简单的例子,修改颜色或者直接更换shader ...

  3. django的聚合函数和aggregate、annotate方法使用

    支持聚合函数的方法: 提到聚合函数,首先我们要知道的就是这些聚合函数是不能在django中单独使用的,要想在django中使用这些聚合函数,就必须把这些聚合函数放到支持他们的方法内去执行.支持聚合函数 ...

  4. HDU 4346 The Beautiful Road ( 反向考虑 思路题 )

    考虑对立情况,不漂亮的串的形式必然为GGGGR……R……RGGGG 相邻R之间的距离为奇数且相等. #include <cstdio> #include <cstring> # ...

  5. Java 循环队列的实现

    队列概念 队列(Queue)是限定只能在一端插入.另一端删除的线性表.允许删除的一端叫做队头(front),允许插入的一端叫做队尾(rear),没有元素的队列称为“空队列”. 队列具有先进先出(FIF ...

  6. 初识 HTML5(一)

    H5其实就是H4的一个增强版本,我们在利用H5进行网页的构造会更简便,标签语义更简洁明了.首先,我们要理解HTML4,它是HTML的标记+css2+JavaScript的一些基本应用,简言之,就是AP ...

  7. CSLM 配置粗解

    CSLM工具(continuous space language model toolkit)用于训练NNLM,支持SRILM.KENLM(默认)语言模型工具,CUDA加速,CSTM统计机器翻译. 本 ...

  8. CS Academy Distinct Neighbours(经典dp)

    CS Academy Distinct Neighbours(经典dp) 题意: 求相邻无相同数字的合法的排列数 题解: 题解 先将相同的数字分为一类,假设共有n组 定义\(dp[i][j]\)表示前 ...

  9. 《c程序设计语言》读书笔记-3.4-数字转字符串

    #include <io.h> #include <stdio.h> #include <string.h> #include <stdlib.h> # ...

  10. HDU 5752

    Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total S ...