ZOJ

来源:互联网 发布:怕死 陈奕迅 知乎 编辑:程序博客网 时间:2024/05/22 01:52

You must have heard that the Chinese culture is quite different from that of Europe or Russia. So some Chinese habits seem quite unusual or even weird to us.

So it is known that there is one popular game of Chinese girls. N girls stand forming a circle and throw a ball to each other. First girl holding a ball throws it to the K-th girl on her left (1 <= K <= N/2). That girl catches the ball and in turn throws it to the K-th girl on her left, and so on. So the ball is passed from one girl to another until it comes back to the first girl. If for example N = 7 and K = 3, the girls receive the ball in the following order: 1, 4, 7, 3, 6, 2, 5, 1.

To make the game even more interesting the girls want to choose K as large as possible, but they want one condition to hold: each girl must own the ball during the game.


This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.


Input

Input file contains one integer number N (3 <= N <= 10^2000) - the number of Chinese girls taking part in the game.


Output

Output the only number - K that they should choose.


Sample Input

2
7
6


Sample Output

3

1

题意:有n个人围成一个圈,编号为1的人有个球,每次向左传给第K个人,问你K最大为几,满足这个球最后回到1手里,并且在此之前经过每个人。

找规律得,如果n是奇数,k=n-1/2,n是偶数的话n/2是偶数的话k=n/2-1   n/2是奇数的话k=n/2-2,然后就是大数相减,大数相除

0 0