Pongdang Pongdang 1
Time limit1sMemory limit256 MB
Given N players and a turn T, find how many arms must be raised on turn T as the count cycles 1,2,...,2N,2N-1,...,1 repeatedly.
- Level
Easy3 of 10
- Topics
- Math, Implementation, Simulation
- Solved
- No attempts yet
Statement
Pongdang Pongdang is a staple drinking game at MT retreats, and teamwork matters most in it. Each turn, a designated number of arms must be raised at the same time, and if the group fails, both the people who were supposed to raise an arm and the people who raised one by mistake must drink as a group punishment. The rules of Pongdang Pongdang are as follows.
- N people, numbered 1 through N, sit in a circle in counterclockwise order. Everyone faces the center of the circle.
- The game starts with person 1's left arm and proceeds from left to right as seen from outside the circle.
- After the first turn, each turn starts from the arm immediately after the rightmost arm raised in the previous turn, and the players raise the designated number of arms in order.
- The number of arms to raise at the start of the game is 1. As turns pass, the number of arms to raise increases by 1 each turn.
- Once the number of arms to raise reaches 2 × N, it decreases by 1 from the next turn onward.
- Once the number of arms to raise reaches 1, it increases by 1 again from the next turn onward.
In other words, the number of arms to raise in each turn stays between 1 and 2 × N.
Jiwon was playing Pongdang Pongdang at an MT retreat and drank too much because of friends who are bad at the game, so he wants to compute how many arms must be raised in each turn. Let us compute exactly how many arms the players must raise on the given turn so that Jiwon survives.
Input
The first line gives the number of players N and the turn T to compute, as integers. (2 ≤ N ≤ 1000, 1 ≤ T ≤ 10^7)
Output
Compute and print the exact number of arms to raise on that turn.