|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|0.5 초 (추가 시간 없음)||512 MB||1||1||1||100.000%|
Carla and Daniel have decided to play heads or tails to decide who will wash the dishes today. They will play with one of the old coins from Carla’s collection. This makes Daniel worried, because these coins are crooked and unbalanced: when tossing a coin, the odds of getting heads and tails are not necessarily equal.
Carla knows her coins well, and can choose one that maximizes her chances of winning. Therefore, Daniel devised a scheme to make the game completely fair, regardless of the chosen coin. First, each will be assigned a nonempty set of binary strings of size N. No string can belong to both, and some strings may not be included in either set. For example, for N = 3, a valid way to distribute the strings would be:
After distributing the strings, Carla and Daniel will toss the same coin N times and write down the sequence of results, where each head equals 0 and each tail equals 1. If the resulting binary string belongs to Carla’s set, she is the winner. If it belongs to Daniel’s set, he is the winner. If the string does not belong to either of them, the coin is tossed another N times to generate a new string. The process is repeated as many times as necessary until they get a winner.
The proper functioning of this scheme depends on the distribution of the strings between Carla and Daniel: the probability of generating a string of the Carla’s set must be equal to the probability of generating a string of Daniel’s set. In other words, let P(S) be the probability that a binary string S of length N will be generated by a sequence of N tosses of the same coin, possibly unbalanced. The total of P for all strings in Carla’s set must be the same as the total of P for all the strings in Daniel’s set.
In addition to distributing the strings fairly, Carla and Daniel want to avoid having to repeat the coin tosses as much as possible, so they want to minimize the number of strings that do not belong to either set. Given N, determine the minimum possible number of unassigned binary strings.
The input consists of a single line, which contains contains an integer number N, the number of coin tosses and binary strings size (2 ≤ N ≤ 1018).
Your program must output a single line, containing an integer, representing the minimum possible number of unassigned binary strings.