【CUGBACM15级BC第26场 A】hdu 5158 Have meal
来源:互联网 发布:yymodel 数组转模型 编辑:程序博客网 时间:2024/05/01 22:54
Have meal
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 951 Accepted Submission(s): 635
Total Submission(s): 951 Accepted Submission(s): 635
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?
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.
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
[Technical Specification]
1<=n, m<=100
Output
For each case, output the number of the mess which I should go to.
Sample Input
4 31 100
Sample Output
20
#include<iostream>using namespace std;int main(){ int n, m; while (cin >> n >> m) { int x = m % n; if (x == 0) { cout << n - 1 << endl; } else { cout << x - 1 << endl; } }}
阅读全文
0 0
- 【CUGBACM15级BC第26场 A】hdu 5158 Have meal
- 【CUGBACM15级BC第15场 A】hdu 5083 Love
- 【CUGBACM15级BC第17场 A】hdu 5100 Chessboard
- 【CUGBACM15级BC第23场 A】hdu 5146 Sequence
- 【CUGBACM15级BC第8场 A】hdu 4989 Summary
- 【CUGBACM15级BC第31场 A】hdu 5178 pairs
- 【CUGBACM15级BC第1场 A】hdu 4857 逃生
- 【CUGBACM15级BC第26场 B】hdu 5159 Card
- 【CUGBACM15级BC第12场 A】【STL】hdu 5058 So easy
- 【CUGBACM15级BC第11场 A】hdu 5054 Alice and Bob
- 【CUGBACM15级BC第13场 A】hdu 5062 Beautiful Palindrome Number
- 【CUGBACM15级BC第18场 A】hdu 5104 Primes Problem
- 【CUGBACM15级BC第20场 A】hdu 5123 who is the best?
- 【CUGBACM15级BC第19场 A】hdu 5108 Alexandra and Prime Numbers
- 【CUGBACM15级BC第21场 A】hdu 5138 CET-6 test
- 【CUGBACM15级BC第22场 A】hdu 5142 NPY and FFT
- 【CUGBACM15级BC第24场 A】hdu 5150 Sum Sum Sum
- 【CUGBACM15级BC第24场 C】hdu 5152 A Strange Problem
- 笔试笔记(八)
- 使用Django建站
- No qualifying bean of type [com.jj.mapper.UserMapper] found for dependency
- Coursera机器学习完结
- 一个在线音乐软件的故事(一、故事的由来)
- 【CUGBACM15级BC第26场 A】hdu 5158 Have meal
- CF808B
- 1002.数字分类
- STL中容器操作的迭代器失效-erase()函数陷阱
- 输入设备框架1—应用层—完整的代码工程
- CodeForces 830C 浅谈奇妙题
- 【CUGBACM15级BC第26场 B】hdu 5159 Card
- NOI2017酱油记(伪)
- The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced