【杭电】[4349]Xiao Ming's Hope

这里写图片描述
这里写图片描述

上次比赛问的是
杨辉三角第n行奇数的个数
和这个本质上是一样的

lucas定理的推广
参考了宇神的博客
hdoj 4349 Xiao Ming’s Hope 【lucas 推广】

#include<stdio.h>
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;
}

题目地址:【杭电】[4349]Xiao Ming’s Hope

posted @ 2016-04-13 22:53  BoilTask  阅读(0)  评论(0编辑  收藏  举报