FHJ seniors wish
The meaning of problems
To give you a number N, so that you find in \ [C ^ {0} _ {n} \ C ^ {1} _ {n} \ C ^ {2} _ {n} \ \ dots \ C ^ {n} _ {n} \] there are several combinations of the number is odd.
Problem-solving ideas
A solution to a problem to the question of seniors who CX:
This question is actually Lucas Theorem examined.
Lucas Theorem :( written procedures may be the second half of recursion)
Set \ (P \) is a prime number, then:
\[C^{m}_{n}(\% P)=C^{m\%P}_{n\%P}∗C^{⌊m/P⌋}_{⌊n/P⌋}(\%P)\]
Sentence, a number of combinations that can be split into (P \) \ product in hexadecimal, following essentially the same as the above Formula :()
\[n = n_{k}*p^{k}+n_{k-1}*p^{k-1}+...+n_{1}*p+n_0\]
\[m = m_{k}*p^{k}+m_{k-1}*p^{k-1}+...+m_{1}*p+m_0\]
Then (in fact it is the formula \ (n, m \) is decomposed into \ (P \) in hexadecimal form):
\[C^{m}_{n}(\% P)=C^{m_{k}}_{n_{k}}∗C^{m_{k-1}}_{n_{k-1}}*...*C^{m_{0}}_{n_{0}}(\%P)\]
When \ (P = 2 \) when, in fact, only four cases: \ (^ 0 ,,,,, C_1, C_0 ^ 1, C_0 ^ 0, C_1 ^ 1 \) , which only \ (C_0 ^ 1 = 0 \) , the rest are 1.
So for this problem, we are actually looking at is \ (C_n ^ 0 ... C_n ^ n \) in the number of \ (C_n ^ m \) satisfies \ (C_n ^ m \% 2 = 1 \) .
For a given \ (n \) , we have to consider \ (m \) , if the corresponding \ (n \) binary bit is 0, then \ (m \) corresponding binary bit can only be 0 (since \ ( ^ 1 = 0 C_0 \) ), if the corresponding \ (n-\) binary bit is 1, then the \ (m \) corresponding to 1 bit may also be zero. (This also ensures statistical \ (m \ the n-Leq \) ).
So the answer is n binary 1 in the position of all of the possible 0 or 1. That \ (CNT 2 ^ {} \) , \ (CNT \) of \ (n-\) number of binary 1's.
The problem was actually found by looking out of the law, really strong.
Code
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
while (scanf("%d", &n) != EOF) {
int cnt = 0;
while (n) {
if (n & 1) cnt++;
n >>= 1;
}
printf("%d\n", 1 << cnt);
}
return 0;
}