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定理,
  1. #include<cstdio>
  2. using namespace std;
  3. int main()
  4. {
  5. int n;
  6. while(~scanf("%d",&n)!=EOF)
  7. {
  8. int num=;
  9. int ans=;
  10. while(n)
  11. {
  12. if(n%==)num++;
  13. n/=;
  14. }
  15. for(int i=;i<=num;i++)ans*=;
  16. printf("%d\n",ans);
  17. }
  18. }

代码狗

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. Js注册等待

    <为维护网上公共秩序和社会稳定,请您自觉遵守以下条款: <br> <br>  一.不得利用本站危害国家安全.泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用 ...

  2. gdb 多线程调试

    gdb 多线程调试 http://hi.baidu.com/hcq11/blog/item/9f5bfc6e696209d680cb4a25.html  http://hi.baidu.com/lit ...

  3. ctags 的最简单使用

    vim插件ctags的安装和使用 2013-11-19 20:47 17109人阅读 评论(0) 收藏 举报  分类: 开发工具(3)  linux编程(9)  c/c++编程(11)  版权声明:本 ...

  4. ASP.NET MVC 随想录——开始使用ASP.NET Identity,初级篇(转)

    ASP.NET MVC 随想录——开始使用ASP.NET Identity,初级篇   阅读目录 ASP.NET Identity 前世今生 建立 ASP.NET Identity 使用ASP.NET ...

  5. Matlab图像处理入门

    1. Matlab基础 1.1     数据格式 Matlab默认的数据格式为双精度浮点数的矩阵或数组,同时支持其它数据类型.Matlab将单变量看作1´1的数组.Matlab支持的数据类型如下: 索 ...

  6. cocos基础教程(1)Mac环境下搭建

    下面主要介绍cocos2d-x环境的设置以及android的环境搭建 1.下载cocos2d-x 3.0正式版      http://www.cocos2d-x.org/download 2.下载a ...

  7. Nginx反向代理 负载均衡

    nginx 这个轻量级.高性能的 web server 主要可以干两件事情: 〉直接作为http server(代替apache,对PHP需要FastCGI处理器支持): 〉另外一个功能就是作为反向代 ...

  8. [Effective JavaScript 笔记]第62条:在异步序列中使用嵌套或命名的回调函数

    异步程序的操作顺序 61条讲述了异步API如何执行潜在的代价高昂的I/O操作,而不阻塞应用程序继续处理其他输入.理解异步程序的操作顺序刚开始有点混乱.例如,下面的代码会在打印"finishe ...

  9. 搭建DNS服务器

    导读 Linux下架设DNS服务器通常是使用Bind程序来实现的.Bind是一款实现DNS服务器的开放源码的软件.DNS即域名系统,主要功能是将人们易于记忆的Domain Name(域名)与不易记忆的 ...

  10. js检测是否安装了flash插件

    function flashChecker() { var hasFlash = 0; //是否安装了flash var flashVersion = 0; //flash版本 var isIE = ...