hdu 4349——Xiao Ming's Hope
来源:互联网 发布:通讯录软件哪个好 编辑:程序博客网 时间:2024/05/21 04:22
题意:给定n,让求c(n,0),c(n,1)……c(n,n)中有多少奇数。
思路:本题为Lucas定理推导题,我们分析一下 C(n,m)%2,那么由lucas定理,我们可以写
- 成二进制的形式观察,比如 n=1001101,m是从000000到1001101的枚举,我们知道在该定理中
- C(0,1)=0,因此如果n=1001101的0对应位置的m二进制位为1那么C(n,m) % 2==0,因此m对应n为0的
- 位置只能填0,而1的位置填0,填1都是1(C(1,0)=C(1,1)=1),不影响结果为奇数,并且保证不会
- 出n的范围,因此所有的情况即是n中1位置对应m位置0,1的枚举,那么结果很明显就是:2^(n中1的个数)
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <sstream>#include <string>#include <vector>#include <list>#include <queue>#include <stack>#include <map>#include <set>#include <bitset>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef long double ld;const int INF=0x3fffffff;const int inf=-INF;const int N=1e5+5;const int M=2005;const int mod=1000000007;const double pi=acos(-1.0);#define cls(x,c) memset(x,c,sizeof(x))#define cpy(x,a) memcpy(x,a,sizeof(a))#define ft(i,s,n) for (int i=s;i<=n;i++)#define frt(i,s,n) for (int i=s;i>=n;i--)#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define lrt rt<<1#define rrt rt<<1|1#define middle int m=(r+l)>>1#define lowbit(x) (x&-x)#define pii pair<int,int>#define mk make_pair#define IN freopen("in.txt","r",stdin)#define OUT freopen("out.txt","w",stdout)int read() { char ch; while (ch = getchar(), !isdigit(ch)); int res = ch - '0'; while (ch = getchar(), isdigit(ch)) res = res * 10 + ch - '0'; return res;}ll powm(ll a,ll n,ll m){ ll ans=1; while (n){ if (n&1) ans=ans*a%m; a=a*a%m; n>>=1; } return ans%m;}//++++++++++++密++++++++++++++封++++++++++++++++++++线int main(){ int n; while (~scanf("%d",&n)){ int sum=0; while (n){ sum+=n&1; n>>=1; } printf("%d\n",(1<<sum)); }}
0 0
- hdu 4349——Xiao Ming's Hope
- HDU 4349--Xiao Ming's Hope
- hdu 4349 Xiao Ming's Hope
- hdu(4349) Xiao Ming's Hope
- HDU 4349 Xiao Ming's Hope
- hdu 4349 Xiao Ming's Hope
- hdu 4349 Xiao Ming's Hope
- HDU 4349 Xiao Ming's Hope
- Xiao Ming's Hope HDU
- HDU 4349 Xiao Ming's Hope 简单的数学—组合数性质
- Xiao Ming's Hope
- Xiao Ming's Hope
- HDU 4349 Xiao Ming's Hope 组合数学
- hdu 4349 Xiao Ming's Hope(Lucas定理)
- HDU 4349 Xiao Ming's Hope(数学题,Lucas定理)
- HDU 4349-Xiao Ming's Hope(Lucas定理的推广)
- hdu 4349 Xiao Ming's Hope,lucas定理
- HDU 4349 Xiao Ming's Hope (Lucas定理的应用)
- linux 命令中tar后跟的zxvf是什么意思呢?
- nohup Execute Commands After You Exit From a Shell Prompt
- Electron-快速上手
- XML解析之SAX解析
- 一切成功源于积累——20160806 美国非农15分钟k线直至收盘 各货币对表现 数据超预期 大杀
- hdu 4349——Xiao Ming's Hope
- Android进程保活之绑定系统服务
- 简单的数论
- mfc使用opencv3.1
- leetcode-刷题经验
- HttpURLConnection
- Unity 客户端框架(六):UI框架
- Dynamically Add Classes with React classSet
- 图片轮播