转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud

How Many Sets I


Time Limit: 2 Seconds      Memory Limit: 65536 KB

Give a set S, |S| = n, then how many ordered set group (S1, S2, ..., Sk) satisfies S1 ∩ S2 ∩ ... ∩ Sk = ∅. (Si is a subset of S, (1 <= i <= k))

Input

The input contains multiple cases, each case have 2 integers in one line represent n and k(1 <= k <= n <= 231-1), proceed to the end of the file.

Output

Output the total number mod 1000000007.

Sample Input

1 1
2 2

Sample Output

1
9

容斥推一下公式,大致就是有一个相交,两个相交。。。。。。

最后可以推出公式是((2^k)-1)^n,还是比较容易得出公式的

 /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author xyiyy @https://github.com/xyiyy
*/ #include <iostream>
#include <fstream> //#####################
//Author:fraud
//Blog: http://www.cnblogs.com/fraud/
//#####################
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <sstream>
#include <ios>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cctype> using namespace std;
typedef long long ll; const ll MOD = ; //
// Created by xyiyy on 2015/8/5.
// #ifndef ICPC_QUICK_POWER_HPP
#define ICPC_QUICK_POWER_HPP
typedef long long ll; ll quick_power(ll n, ll m, ll mod) {
ll ret = ;
while (m) {
if (m & ) ret = ret * n % mod;
n = n * n % mod;
m >>= ;
}
return ret;
} #endif //ICPC_QUICK_POWER_HPP class TaskH {
public:
void solve(std::istream &in, std::ostream &out) {
int n, k;
while (in >> n >> k) {
ll ans = quick_power(, k, MOD) - ;
ans = (ans + MOD) % MOD;
ans = quick_power(ans, n, MOD);
out << ans << endl;
}
}
}; int main() {
std::ios::sync_with_stdio(false);
std::cin.tie();
TaskH solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return ;
}

ZOJ3556 How Many Sets I(容斥)的更多相关文章

  1. How Many Sets I(容斥定理)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3556 How Many Sets I Time Limit: 2 ...

  2. TOJ 4008 The Leaf Eaters(容斥定理)

    Description As we all know caterpillars love to eat leaves. Usually, a caterpillar sits on leaf, eat ...

  3. POJ1091跳蚤(容斥 + 唯一分解 + 快速幂)

      题意:规定每次跳的单位 a1, a2, a3 …… , an, M,次数可以为b1, b2, b3 …… bn, bn + 1, 正好表示往左,负号表示往右, 求能否调到左边一位,即 a1* b1 ...

  4. HDU 4059 容斥初步练习

    #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> ...

  5. HDU 4336 Card Collector (期望DP+状态压缩 或者 状态压缩+容斥)

    题意:有N(1<=N<=20)张卡片,每包中含有这些卡片的概率,每包至多一张卡片,可能没有卡片.求需要买多少包才能拿到所以的N张卡片,求次数的期望. 析:期望DP,是很容易看出来的,然后由 ...

  6. 【BZOJ-4455】小星星 容斥 + 树形DP

    4455: [Zjoi2016]小星星 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 204  Solved: 137[Submit][Status] ...

  7. cf#305 Mike and Foam(容斥)

    C. Mike and Foam time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  8. UVa12633 Super Rooks on Chessboard(容斥 + FFT)

    题目 Source http://acm.hust.edu.cn/vjudge/problem/42145 Description Let’s assume there is a new chess ...

  9. PE-1 & 暴模|容斥

    题意: 求1000以下3或5的倍数之和. SOL: 暴模也是兹瓷的啊... 那么就想到了初赛悲催的滚粗...容斥忘了加上多减的数了... 然后对着题...T = 3*333*(1+333)/2 + 5 ...

随机推荐

  1. Drupal建站过程思考——不识庐山真面目,只缘身在此山中

    使用drupal与没有使用drupal,在网站的设计过程上本质是一样的!所以,我们在使用drupal建一个新网站时,要时刻联想自己在没有drupal时是如何设计开发的. 不使用drupal时,我们通常 ...

  2. JSP九大隐式对象

    JSP九大隐式对象 request HttpServletRequest response HttpServletResponse session HttpSession application Se ...

  3. 使用minidwep-gtk-PJ-wifi教程中文版

  4. new Date参数问题

    new Date支持的参数: MDN:   new Date();   new Date(value);   new Date(dateString);   new Date(year, month, ...

  5. sizeof用法研究

    一.基础研究 写一个c程序,打印int.long.double型变量所占的字节数.地址.各个字节的地址和内容.打印地址和内容比较好办,打印地址可以用取址符&,打印内容直接输出就行了,那么怎么打 ...

  6. 在网页中获取 facebook page 的内容

    参考 : http://www.ibm.com/developerworks/cn/opensource/os-cn-facebookapi/ 1.首先你要有 facebook page, 内容要公开 ...

  7. java交通灯管理系统项目

    交通灯管理系统   模拟实现十字路口的交通灯管理系统逻辑,具体需求如下: 异步随机生成按照各个路线行驶的车辆. 例如: 由南向而来去往北向的车辆 ---- 直行车辆 由西向而来去往南向的车辆 ---- ...

  8. COJ 0252 HDNOIP201304阻断传染

    HDNOIP201304阻断传染 难度级别: A: 编程语言:不限:运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 H国有n个城市,n个城市用n ...

  9. 如何把SKYPE的发送消息由enter改为ctrl+enter?

    如果您的skype是tom-skype3.8正式版.您可以在skype面板中,选择"工具"-"选项"-"会话"-"会话设置&quo ...

  10. 【细说Java】Java变量初始化顺序

    Java的变量初始化顺序,对这里一直似懂非懂,面试的时候也经常被问到,但答的一直不好,现在整理记录一下,以后忘记了可以来看看. 程序分为两个部分,第一个部分不考虑继承,第二个部分考虑继承: (1)不考 ...