Enter an n (1<=n<=108), C (n,0), C (n,1), C (n,2) ... C (N,n) has the number of odd numbers.
Lacus theorem http://blog.csdn.net/acm_cxlove/article/details/7844973
A, B is a non-negative integer and P is a prime number. AB is written in P-system: a=a[n]a[n-1]...a[0],b=b[n]b[n-1]...b[0].
The combined number C (A, B) and C (A[n],b[n]) *c (a[n-1],b[n-1]) *...*c (a[0],b[0]) MODP the same
So in this topic C (n, x) will n and X into 2 C (0,0) =1,c (0,1) =0,c (1,0) =1,c (a) =1
So if C (n,x) is 1, then n is 0 where x must be 0,n 1, where x is 0 or 1
The answer is 2^ (the binary of n represents the number of 1)
#include <iostream> #include <cstdio> #include <cmath>using namespace Std;int main () { int n, c; while (~SCANF ("%d", &n)) { c = 0; while (n) { if (N & 1) ++c; n >>= 1; } printf ("%d\n", (int) POW (2, c)); } return 0;}
Hdu4349--xiao Ming ' s Hope (number theory)