题目链接:
HDU 4349 Xiao Ming’s Hope
题意:
给定
n
求
分析:
即
Cmn %2=1的m个数
,考虑将
n和m
都表示成
2
的幂次组合形式,则任意的系数
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
typedef long long ll;
int main()
{
int n, cnt;
while(~scanf("%d", &n)) {
cnt = 0;
while (n) {
if (n & 1) cnt ++;
n >>= 1;
}
printf("%d\n", 1 << cnt);
}
return 0;
}

本文介绍了解决HDU4349 XiaoMing's Hope问题的方法,该问题要求找出组合数Cnm为奇数时m的个数。通过使用Lucas定理,并将n表示为2的幂次组合,分析了各情况下m的选择,最终得出解题公式。
551

被折叠的 条评论
为什么被折叠?



