Some people have such a number in the forum, asking for a number, the number of bit numbers is 2, when moving 2 on the 2nd place, this number is twice the number of ranules.
At first I used a loop, no fruit, it is estimated that this number may be very huge. After the analysis algorithm, it can be simplified:
#include
It is set to be evaluated, and the integer b is made, so that the value of B is equal to the value of the highest bit, and A satisfies two conditions: 1. A number of bit numbers 22. B = 2A
Algorithm E1. Initial A is 1, B is 2
E2. Queu A number of bit numbers and assignes P
E3. If P = 2 shows a first condition that satisfies the number, if B can be removed, the second condition is satisfied, then the number, the output result, exit the program.
E4. If you do not meet the above two conditions, then the order B shifts one bit based on 10 feed, and assigns a bit to P. (Give Point to P is to satisfy "the value of B is equal to the value of the one-shift movement to the highest bit")
E5. Let a = B / 2
E6. Jump to E2 to continue judgment.
However, the algorithm is not universal, the number is very huge, and __INT64 must be used to support the operation, and the efficiency is low. Optimized again to obtain a pure C code algorithm.
#include