Hdu4349--xiao Ming ' s Hope (number theory)

Source: Internet
Author: User
Tags ming

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.