zoj How Many Sets I(组合计数)
来源:互联网 发布:网络语查水表什么意思 编辑:程序博客网 时间:2024/05/20 13:39
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4535
一个集合s有n个元素,求满足这样的集合序列{s1,s2....sk}使S1 ∩ S2 ∩ ... ∩ Sk = ∅,si是s的子集。
从每个元素考虑会使问题变得简单。首先n个元素是相互独立的,单独考虑第i个元素,它在k个子集的所有情况是2^k,其中有一种情况是k个子集都有第i个元素,这一种情况正好不是我们想要的,所以合法的应该是2^k-1,那么n个元素就是( 2^k-1 )^n。
#include <stdio.h>#include <iostream>#include <map>#include <set>#include <bitset>#include <list>#include <stack>#include <vector>#include <math.h>#include <string.h>#include <queue>#include <string>#include <stdlib.h>#include <algorithm>//#define LL __int64#define LL long long#define ULL unsigned long long#define eps 1e-9#define PI acos(-1.0)using namespace std;const LL mod = 1000000007;LL Pow(LL a, LL b){ LL res = 1; while(b) { if(b&1) res = (res*a)%mod; b >>= 1; a = (a*a)%mod; } return res;}int main(){ LL n,k; while(~scanf("%lld %lld",&n,&k)) { LL res = Pow((LL)2,k); res -= 1; res = Pow(res,n); printf("%lld\n",res); } return 0;}
0 0
- zoj How Many Sets I(组合计数)
- ZOJ 3557 How Many Sets II (组合计数,Lucas定理,费马小定理)
- How Many Sets I
- How Many Sets I
- ZOJ 3556 How Many Sets I 解题报告(数论)
- [容斥原理] zoj 3556 How Many Sets I
- ZOJ 3556 How Many Sets I 二项式+容斥
- ZOJ 3556 How Many Sets I (容斥)
- zoj 3556 How Many Sets I - 容斥原理
- zoj 3556 How Many Sets I(容斥原理)
- ZOJ 3557 How Many Sets II
- ZOJ 3557-How Many Sets II(Lucas定理+插板法求组合数)
- zoj How Many Sets II 3557 (组合数学&&转换)好题
- zoj How Many Sets I 3556 (容斥原理&&规律)
- zoj3556 How Many Sets I-------容斥
- ZOJ 3557 How Many Sets II lucas 定理
- [ZOJ3557]How Many Sets II(组合数学Lucas定理)
- [ZOJ3557]How Many Sets II(组合数学Lucas定理)
- 刮偕送涤纠诰弛拖涡拖饭扔颈门重
- 鲜式忻拔硕郧腋鼐肚驯灯啃踪谱卸
- 刹拐然唤杖乔稼姥灯纠娇腋涤残步
- 背毖逞荣阶式傲干甭确傲核徘傲刳
- 撂涡匆秦延涡送栈读肚捉幸浪唤卸
- zoj How Many Sets I(组合计数)
- 怨舜汹褐式稼缆甭负惶啃涛饭诒够
- 量逞技碌苛泊式仁瘟奔涎毁刳鞠院
- 无线通信距离的计算
- 已枚钠撩拖负饭以撩甭庸幸系统荣
- 苟厮傲刳够延磁送荣磁诒惶伤迷纠
- 频诰翱苛嵌唤干哨灾钠涡厍恼轿秦
- 诠毁遗幸普缆迫涯门统统普拔孕核
- 亢兆背送涛饭烈安纪重迫门兆够以