246. Black & White
time limit per test: 0.25
memory limit per test: 65536
Consider a necklace made of 2N-1 black and white beads, K of which are black. Necklace is called "beautiful" if it is possible to choose two black beads (not necessarily different) in such a way that one of two necklace parts strictly between them contains exactly N beads.
For example, if N=4 and K=3, necklace "WBWBWBW" is beautiful, and necklace "BBWWBWW" is not.
You need to find minimal K for which every necklace of 2N-1 beads is beatiful.
The first line of input contains odd integer number 2N-1 (5<=2N-1<=2^31-1).
Output minimal K for which every necklace of 2N-1 beads is beatiful.
|Resource:||Petrozavodsk Summer Training Sessions 2004
|Date:||August 25, 2004
|Server time: 2017-11-23 19:46:42||Online Contester Team © 2002 - 2016. All rights reserved.|