BestCoder Round #26 HDU5158 Have meal
2015-10-04 21:50
190 查看
Have meal
TimeLimit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 637 Accepted Submission(s): 440
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
BestCoder Round #26
相关文章推荐
- 模板和宏的区别
- [深入理解Java虚拟机]第二章 实战 :OutOfMemoryError异常
- hiho一下 第六十六周
- android安卓布局总结
- 通过代码自定义cell(cell的高度不一致)
- CPPUTest 单元测试框架(针对 C 单元测试的使用说明)
- 1034. 有理数四则运算(20)
- 在CentOS 6 X64下安装Docker
- 【python】抄写大神的糗事百科代码
- hiho一下 第六十六周
- jsonobject 遍历 org.json.JSONObject
- 使用jersey(2.5.1)编写Java REST客户端
- Matlab-vision包学习-Feature Detection,Extraction and Matching-MSER特征提取
- 第三节 信息的表示和处理
- Spark修炼之道(基础篇)——Linux大数据开发基础:第十节:Shell编程入门(二)
- nginScript笔记
- mysql query cache用法与性能详细介绍
- 漫谈字符集和编码
- java的集合类
- jmeter入门教程- Jmeter教程及技巧汇总