猴子选大王

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

n只猴子选大王,选举办法如下:从头到尾1,2,3报数,凡报3的退出,余下猴子第二轮从尾到头1,2,3报数,凡报3的退出...如此类推,当剩下两只猴子时,取这时报1的为王,若想当猴王,请问当初应占据什么位置?

输入格式

一个数 n,表示n只猴子 n<=1000 .

输出格式

一个整数,表示猴王的位置,也就是最后一个出队的猴子的位置。

样例

input

3

===================下面为第二组======================

7

output

2

===================下面为第二组======================

2

限制与提示

时间限制:1s1 \text {s}

空间限制:256MB256 \text {MB}

寒假集训_01_15

Not Attended
Status
Done
Rule
XCPC
Problem
21
Start at
2025-1-15 14:00
End at
2025-1-15 17:00
Duration
3 hour(s)
Host
Partic.
38