读入n,输出
样例输入:10
样例输出: 36
数据范围: 0<n<10^7
Analysis: We only need to calculate the number of odd binomial coefficients.
Points:
1. C(n,k) is odd if and only if n&k==k(0<=k<=n);
2. Fix one i, we only need to count how many "1"s in its binary form and the odd binomial coefficients in this equivalence class(i) is clearly 2^k;(Use the quick calculation of "1"s in a binary number)
As for the first point, we prove it by using the method of mathematical induction on the level n of the Pascal Triangle.
First we check the base step. When the level is 1,2,3, it is quite obvious that the statement is true.
Then we check the