非常无语的一个题。

反正我后来看题解全然不是一个道上的。

要用什么组合数学的lucas定理。

表示自己就推了前面几个数然后找找规律。

C(n, m) 就是 组合n取m;

(m!(n-m!)/n!)

假设n==11 ;

C(11,0);C(11,1);C(11,2);C(11,3);C(11,4);C(11,5);

分别为

(1/1); (1 / 11) ; (11*10 / 2*1)  ;   (11*10*9 / 3*2*1); (11*10*9*8 / 4*3*2*1) ;  (11*10*9*8*7 / 5*4*3*2*1);

C(11,11);C(11,10);C(11,9);C(11,8);C(11,7);C(11,6);

这两个都是相等的。(參见排列组合)

若要 C(n,m)为奇数,必须  分子分母 约分后都是奇数。

发现假设纯模拟的肯定会超时的。

当时发现 当n==2^?  都是能够被除掉的,就仅仅有 C(n,0);和 C(n,n) 都是 1,奇数。

而 n==(2^?)-1 的时候结果就是 2^n 。

然后推了前面几个数

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16

2,2,4,2,4,4,8,2,4,4  ,8  ,4  ,8  ,8  ,16,2

巨像 树状数组。。。想到树状数组是取& 。

然后我就 转换 n 的二进制。发现有m个1 ,结果就是 2^m ;

于是最终AC。→ _ → 数学好伐。

#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<iostream>
#include<list>
#include<set>
#include<cmath>
#define INF 0x7fffffff
#define eps 1e-6
using namespace std;
int shift(int n)
{
int cot=0;
while(n)
{
if(n%2==1)cot++;
n/=2;
}
return cot;
}
int main()
{
int n,m;
while(scanf("%d",&n)!=EOF)
{
m=shift(n);
cout<<pow(2,m)<<endl;
}
}

HDU 4349 Xiao Ming&#39;s Hope的更多相关文章

  1. 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/ ...

  2. HDU 4349 Xiao Ming's Hope lucas定理

    Xiao Ming's Hope Time Limit:1000MS     Memory Limit:32768KB  Description Xiao Ming likes counting nu ...

  3. hdu 4349 Xiao Ming's Hope 规律

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

  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's Hope

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

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. HDU 5433 Xiao Ming climbing dp

    Xiao Ming climbing Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/ ...

随机推荐

  1. 数据结构读书笔记(二)(C语言)

    (一)循环链表 存储类型 typedef struct LNode { ElemType data; struct LNode *next; }; typedef struct LNode *Link ...

  2. Java NIO内存映射---上G大文件处理(转)

    林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 摘要:本文主要讲了java中内存映射的原理及过程,与传统IO进行了对比,最后,用实例说明了结果 ...

  3. A WPF File ListView and ComboBox

    源码下载: Download FileListView_Version_2.zip Download FileListView_Version_2_Binaries.zip Download File ...

  4. Java Swing 绝对布局管理方法,null布局(转)

    首先把相关容器的布局方式设为 setLayout(null); 然后调用组件的  setBounds() 方法 设置button的位置为(100,100) 长宽分别为 60,25 jButton.se ...

  5. Android lint具 常见问题检查

    1. Correctness 1) DuplicatedIds Layout于id应该唯一 2) NewApi 代码中使用的某些API高于Manifest中的Min SDK 3) Inconsiste ...

  6. 认识node.js:express(一)

    express是node.js官方推荐的框架. 安装 npm install express -g 命令中的 “-g” 表示全局(global) 由于新版本(4.x.x)的express的命令集中到了 ...

  7. [LeetCode228]Summary Ranges

    题目: Given a sorted integer array without duplicates, return the summary of its ranges. For example, ...

  8. cocospods 卡在 Analyzing dependencies

    參考链接:http://www.cocoachina.com/bbs/read.php? tid=193398 关于pod stetup的详解在这里.对于初次使用CocoaPods的同学,即使你不使用 ...

  9. cocos2d_x_06_游戏_一个都不能死

    终于效果图: 环境版本号:cocos2d-x-3.3beta0 使用内置的物理引擎 游戏主场景 // // HeroScene.h // 01_cocos2d-x // // Created by b ...

  10. 探索Windows Azure 监控和自动伸缩系列2 - 获取虚拟机的监控定义和监控数据

    上一篇博文介绍了如何连接Windows Azure: http://www.cnblogs.com/teld/p/5113063.html 本篇我们继续上次的示例代码,获取虚拟机的监控定义和监控数据. ...