2266.Collective Mindsets (medium)

Time Limit: 1s Memory Limit: 256MB

Way to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of brains that must be in the chest for her to get out at all (possibly empty-handed, but alive)?

The brain dinner night will evolve just as in the previous subtask: the same crowd is present, the N-1 zombies have the exact same mindset as before and Heidi is to make the first proposal, which must be accepted by at least half of the attendees for her to survive.

Input Format(From the terminal/stdin)

The only line of input contains one integer: N, the number of attendees (1 \le N \le 109).

Output Format(To the terminal/stdout)

Output one integer: the smallest number of brains in the chest which allows Heidi to merely survive.

Sample Input 1

Copy
1
 \n

Sample Output 1

Copy
0
 \n

Sample Input 2

Copy
3
 \n

Sample Output 2

Copy
1
 \n

Sample Input 3

Copy
99
  \n

Sample Output 3

Copy
49
  \n

Submit

请先 登录

© 2025 FAQs