Xiao Ming's Hope

Time Limit:1000MS     Memory Limit:32768KB 

Description

Xiao Ming likes counting numbers very much, especially he is fond of counting odd numbers. Maybe he thinks it is the best way to show he is alone without a girl friend. The day 2011.11.11 comes. Seeing classmates walking with their girl friends, he coundn't help running into his classroom, and then opened his maths book preparing to count odd numbers. He looked at his book, then he found a question "C(n,0)+C (n,1)+C (n,2)+...+C (n,n)=?". Of course, Xiao Ming knew the answer, but he didn't care about that , What he wanted to know was that how many odd numbers there were? Then he began to count odd numbers. When n is equal to 1, C (1,0)=C (1,1)=1, there are 2 odd numbers. When n is equal to 2, C (2,0)=C (2,2)=1, there are 2 odd numbers...... Suddenly, he found a girl was watching him counting odd numbers. In order to show his gifts on maths, he wrote several big numbers what n would be equal to, but he found it was impossible to finished his tasks, then he sent a piece of information to you, and wanted you a excellent programmer to help him, he really didn't want to let her down. Can you help him?
 

Input

Each line contains a integer n(1<=n<=10 8)
 

Output

A single line with the number of odd numbers of C (n,0),C (n,1),C (n,2)...C (n,n).
 

Sample Input

1 2 11
 

Sample Output

2 2 8
题意:
求C (n,0),C (n,1),C (n,2)...C (n,n).中的奇数个数
题解:
  lucas定理,
#include<cstdio>
using namespace std;
int main()
{
int n;
while(~scanf("%d",&n)!=EOF)
{
int num=;
int ans=;
while(n)
{
if(n%==)num++;
n/=;
}
for(int i=;i<=num;i++)ans*=;
printf("%d\n",ans);
}
}

代码狗

HDU 4349 Xiao Ming's Hope lucas定理的更多相关文章

  1. HDU 4349 Xiao Ming's Hope [Lucas定理 二进制]

    这种题面真是够了......@小明 题意:the number of odd numbers of C(n,0),C(n,1),C(n,2)...C(n,n). 奇数...就是mod 2=1啊 用Lu ...

  2. hdu 4349 Xiao Ming's Hope lucas

    题目链接 给一个n, 求C(n, 0), C(n, 1), ..........C(n, n)里面有多少个是奇数. 我们考虑lucas定理, C(n, m) %2= C(n%2, m%2)*C(n/2 ...

  3. HDU 4349 Xiao Ming's Hope 找规律

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4349 Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/ ...

  4. HDU 4349——Xiao Ming's Hope——————【Lucas定理】

    Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  5. HDU 4349 Xiao Ming&#39;s Hope

    非常无语的一个题. 反正我后来看题解全然不是一个道上的. 要用什么组合数学的lucas定理. 表示自己就推了前面几个数然后找找规律. C(n, m) 就是 组合n取m: (m!(n-m!)/n!) 假 ...

  6. hdu 4349 Xiao Ming's Hope 规律

    Xiao Ming's Hope Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. HDU 4349 Xiao Ming's Hope 组合数学

    题意:给你n,问在C(n,1),C(n,2)...C(n,n)中有多少个奇数. 比赛的时候打表看出规律,这里给一个数学上的说明. Lucas定理:A,B非负整数,p是质数,A,B化为p进制分别为a[n ...

  8. HDU 4349 Xiao Ming's Hope

    有这样一个性质:C(n,m)%p=C(p1,q1)*C(p2,q2).......%p,其中pkpk-1...p1,qkqk-1...q1分别是n,m在p进制下的组成. 就完了. #include&l ...

  9. 数论(Lucas定理) HDOJ 4349 Xiao Ming's Hope

    题目传送门 题意:求C (n,0),C (n,1),C (n,2)...C (n,n)中奇数的个数 分析:Lucas 定理:A.B是非负整数,p是质数.AB写成p进制:A=a[n]a[n-1]...a ...

随机推荐

  1. Silverlight实例教程 – Datagrid,Dataform数据验证和ValidationSummary(转载)

    Silverlight 4 Validation验证实例系列 Silverlight实例教程 - Validation数据验证开篇 Silverlight实例教程 - Validation数据验证基础 ...

  2. html5浮动、等高、弹性盒模型

    1px dashed虚线 box-sizing拯救了布局 1.inherit  继承父级 2.content-box(默认)-----这个盒子的边框.内边距 这2个值是不包括在width和height ...

  3. Hibernate unsaved-value 属性

    Session的saveOrUpdate方法是由Hibernate来判断被操作对象究竟是一个持久化对象还是临时自由状态对象.这需要在对象映射文件的主键id中定义unsaved-value属性,如果不显 ...

  4. Hello world,Hello 2014,Bye 2013

    序 想要写点什么的时候发现不知道写什么了,用一句话来总结2013的话,就是2013是既熟悉又陌生的一年,熟悉是同样的开发工作,陌生是从河南到北京的环境改变,当时大学的卧谈会,谈论毕业了要做什么,想要在 ...

  5. Debian普通用户添加sudo权限

    转自:http://chenpeng.info/html/964 刚安装好的Debian默认还没有sudo功能.1.安装sudo# apt-get install sudo2.修改 /etc/sudo ...

  6. Java转义符\\|

    http://blog.csdn.net/stewen_001/article/details/22871737 看一段程序 String t = "a||b||c||d"; St ...

  7. Android开源项目第二篇——工具库篇

    本文为那些不错的Android开源项目第二篇——开发工具库篇,**主要介绍常用的开发库,包括依赖注入框架.图片缓存.网络相关.数据库ORM建模.Android公共库.Android 高版本向低版本兼容 ...

  8. OpenSwitch操作系统成为Linux基金会官方项目

    导读 非盈利机构Linux基金会为推进Linux和开源软件在企业和专业人士的发展,于今天宣布OpenSwitch项目成为Linux基金会官方项目之一. Linux基金会的常务董事Jim Zemlin表 ...

  9. [BZOJ1061][Noi2008]志愿者招募

    [BZOJ1061][Noi2008]志愿者招募 试题描述 申奥成功后,布布经过不懈努力,终于成为奥组委下属公司人力资源部门的主管.布布刚上任就遇到了一个难 题:为即将启动的奥运新项目招募一批短期志愿 ...

  10. DICOM:DICOM标准学习路线图(初稿)

    题记: DICOM医学图像处理专栏撰写已有两个年头,积累了近百篇文章.起初只是用于记录自己科研.工作中遇到的疑难问题,专注于图像处理(主要是医学图像,这也正是专栏名称最初的由来):后来逐渐延伸到了DI ...