Pro.ID22141 TitleGod of gamblers Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22141 AC1 Submit23 Ratio4.35% 时间&空间限制描述Have you ever seen the movie "God of gamblers"? Yes. it's very exciting! You must be attracted by the deft skill of the god of gamblers. He can play the cards as he wish. The action of shuffling cards is extremely handsome. How I wish I had such a pair of hands! However, it will he only a dream forever. There is a popular method of shuffling cards. Suppose you have a stack ot 2×n cards. Divide them into two stacks, one with the first n cards while another with the last n cards. Then mix the two stacks of cards uniformly. That is the i-th card of the original stack is placed in the p(i)-th position of the new stack where p(i) is a function defined like this: Give you an integer n. Calculate the minimum positive number of shuffles that makes the cards have the same order as the original stack. 输入A line containing an integer n which is less than 109. There are multiple test cases. lnput will be terminated by EOF. 输出Description Have you ever seen the movie "God of gamblers"? Yes. it's very exciting! You must be attracted by the deft skill of the god of gamblers. He can play the cards as he wish. The action of shuffling cards is extremely handsome. How I wish I had such a pair of hands! However, it will he only a dream forever. There is a popular method of shuffling cards. Suppose you have a stack ot 2×n cards. Divide them into two stacks, one with the first n cards while another with the last n cards. Then mix the two stacks of cards uniformly. That is the i-th card of the original stack is placed in the p(i)-th position of the new stack where p(i) is a function defined like this: Give you an integer n. Calculate the minimum positive number of shuffles that makes the cards have the same order as the original stack. Input A line containing an integer n which is less than 109. There are multiple test cases. lnput will be terminated by EOF. Output A line containing an integer which indicates the minimum positive number of shuffles. Sample Input 1 Sample Output 2 Source 样例输入1 样例输出2 作者 |