CDOJ 1268 Open the lightings
组合数学题。好难啊,请教了Xiang578大神&&看了他题解才会的......
甩上题解链接:http://blog.csdn.net/xinag578/article/details/50645160
另外还发现了组合数递推公式实际上就是一个01背包。
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <queue>
#include <stack>
#include <map>
#include <vector>
using namespace std; const int maxn=+;
long long MOD=1e9+;
long long f[maxn];
long long c[maxn][maxn]; void init()
{
f[]=,f[]=;
for(int i=;i<=;i++) f[i]=(f[i-]+((i-)*f[i-])%MOD)%MOD; c[][]=;
for(int i=;i<=;i++) c[i][]=;
for(int i=;i<=;i++)
{
for(int j=;j<=;j++)
{
c[i][j]=(c[i-][j-]+c[i-][j])%MOD;
}
}
} int main()
{
init();
int n,m;
while(~scanf("%d%d",&n,&m))
{
printf("%lld\n",f[m-]*f[n-m]%MOD*c[n-][m-]%MOD);
} return ;
}
CDOJ 1268 Open the lightings的更多相关文章
- 51Nod 1268 和为K的组合
51Nod 1268 和为K的组合 1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 给出N个正整数组成的数组A,求能否从中选出若干个,使 ...
- cdoj 1489 老司机采花
地址:http://acm.uestc.edu.cn/#/problem/show/1489 题目: 老司机采花 Time Limit: 3000/1000MS (Java/Others) M ...
- ural 1268. Little Chu
1268. Little Chu Time limit: 0.25 secondMemory limit: 64 MB The favorite occupation of Little Chu is ...
- CCPC2017湘潭 1263 1264 1267 1268
1263 拉升一下就A了 #include <iostream> #include <vector> #include <algorithm> #include & ...
- 51Nod:1268 和为K的组合
1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 收藏 关注 给出N个正整数组成的数组A,求能否从中选出若干个,使他们的和为K.如果可以 ...
- 1268 和为K的组合 Meet in mid二分思路
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1268&judgeId=193772 给出n = 20个数,问其是 ...
- CDOJ 1324 卿学姐与公主(分块)
CDOJ 1324 卿学姐与公主(分块) 传送门: UESTC Online Judgehttp://acm.uestc.edu.cn/#/problem/show/1324 某日,百无聊赖的卿学姐打 ...
- CDOJ 1330 柱爷与远古法阵(高斯消元)
CDOJ 1330 柱爷与远古法阵(高斯消元) 柱爷与远古法阵 Time Limit: 125/125MS (Java/Others) Memory Limit: 240000/240000K ...
- 51nod 1268 和为K的组合 dfs
题目: 1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 给出N个正整数组成的数组A,求能否从中选出若干个,使他们的和为K.如果可以,输出:& ...
随机推荐
- Windsock套接字I/O模型学习 --- 第一章
1. I/O模型共有以下几种: 阻塞(blocking)模型 选择(select)模型 WSAAsyncSelect模型 WSAEventSelect模型 重叠(overlapped)模型 完成端口( ...
- iOS 判断数组不为空
if (array != nil && ![array isKindOfClass:[NSNull class]] && array.count != 0)
- 使用devcon禁用启用网卡
系统平台:win2003 情况描述: 机器上装有两块网卡,8136和8139,网卡A使用静态IP,连接内部办公网,网卡B使用DHCP,连接互联网.切换两个网络时,需要先禁用一个网卡,启用另一个网卡.来 ...
- js html 交互监听事件学习
事件处理程序(handler): HTML事件处理程序: <input type="button" value="Click Here" onclick= ...
- Php和httpd.conf的配置
http://www.cnblogs.com/homezzm/archive/2012/08/01/2618062.html http://book.51cto.com/art/201309/4096 ...
- listview去掉条目间的分割线
未去掉前: 去掉后: java代码可以这么写: 1 listView.setDivider(null);//去掉条目间的分割线 PS:ListView的几个常用操作 listView ...
- OSPF的基本配置及DR /BDR选举的实验
OSPF的基本配置及DR /BDR选举的实验 实验拓扑: 实验目的:掌握OSPF的基本配置 掌握手工指定RID 掌握如何修改OSPF的接口优先级 观察DR BDR选举的过程 实验要求:R3当选为DR ...
- android4.0蓝牙使能的详细解析(转)
源:http://www.cnblogs.com/xiaochao1234/p/3818193.html 本文详细分析了android4.0 中蓝牙使能的过程,相比较android2.3,4.0中的蓝 ...
- 使用Spring框架的好处(转帖)
http://blog.csdn.net/cynhafa/article/details/6205361 在SSH框假中spring充当了管理容器的角色.我们都知道Hibernate用来做持久层,因为 ...
- 利用cookie实现“只弹出一次窗口”的JS代码
弹出式窗口通常被用来做弹出广告(CPM),其实用弹出式窗口用来做消息通知也是最普遍而且是最有效的方法,但如果每次刷新页面特别是刷新首页都要弹出窗口的话,那绝对是让访问者厌烦的事情. 比如你将上面的脚本 ...