非常无语的一个题。

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

要用什么组合数学的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. document.getElementById()使用方法

    document.getElementById使用 语法:oElement = document .getElementById ( sID ) 參数:sID――必选项. 字符串 (String) . ...

  2. 使用MVC写模式jsp连接到数据库操作

    首先用一个JavaBean封装数据库操作,即mvc中的模型 JdbcBean.java package data; import java.sql.*; public class JdbcBean { ...

  3. 区间第K大

    protected static int partitions(List<KDNode> data,int left,int right,int k,int pos){ int l = l ...

  4. Linux下常用操作汇总

    查看linux操作系统位数 (1) 终端输入: file /sbin/init 如 显示: /sbin/init: ELF 32-bit LSB executable, Intel 80386, ve ...

  5. Eclipse工具的问题

    1 Eclipse采用ctrl抄 粘贴很卡 Eclipse -- Windows->Preferences->General->Editors->Text Editors-&g ...

  6. JQuery操作select checkbox radio总结

    JQuery是一个非常强大的工具,所以我必须找到它最方便的方法,嘻嘻 Select CRUD: Select搜: 1.val值: $("#selectid").val();     ...

  7. 【Linux探索之旅】第二部分第一课:终端Terminal,好戏上场

    内容简介 1.第二部分第一课:终端Terminal,好戏上场 2.第二部分第二课预告:命令行,世界尽在掌握 终端Terminal,好戏上场 随着第一部分的结束,我们进入了第二部分(小编你这好像是废话. ...

  8. APK 代码混淆

    # To enable ProGuard in your project, edit project.properties # to define the proguard.config proper ...

  9. UVA How Big Is It?

    题目例如以下: How Big Is It?  Ian's going to California, and he has to pack his things, including hiscolle ...

  10. * 类描写叙述:字符串工具类 类名称:String_U

    /****************************************** * 类描写叙述:字符串工具类 类名称:String_U * ************************** ...