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.如果可以,输出:& ...
随机推荐
- Ugly Problem
Ugly Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Spec ...
- 字符串编码问题(Ascii、Unicode、UCS-2、GBK、UTF-8)
1.字符编码的发展 第一阶段:ASCII阶段,(American Standard Code for Information Interchange, "美国信息交换标准码),计算机当时只支 ...
- java 反射的实例
JAVA反射机制是在运行状态中,对于任意一个类,都能够得到这个类的所有属性和方法;对于任意一个对象,都能够调用它的任意一个方法;这种动态获取的信息以及动态调用对象的方法的功能称为java语言的反射机制 ...
- div.2/C. They Are Everywhere<two pointer>
题意: 给出包含n (3<=n<=100000)个字符的字符串,计算出包含所有类型字符的最小区间长度. 题解: Two pointer.注意区间的处理. #include<cstdi ...
- unity LineRenderer
using UnityEngine; using System.Collections; public class Spider:MonoBehaviour { private LineRendere ...
- [转]Linux下CodeBlocks的交叉编译
原文链接:http://blog.sina.com.cn/s/blog_602f87700100kujh.html Sam一直是Makefile流,这些天需要移植一些游戏引擎模块.这些模块在其它嵌入式 ...
- 【python之路10】python实例练习
#!usr/bin/env python # -*- coding:utf-8 -*- # 一.元素分类 # # 有如下值集合 [11,22,33,44,55,66,77,88,99,90...], ...
- L5,no wrong numbers
expressions: up to now,到现在为止 a great many,数量很大 in a way,在某种意义上说 words: burn,vt燃烧,vi烧毁,n灼烧 obtain,v ...
- jquery 延迟执行实例介绍
代码如下: $(function(){ var $inputs = $('input[type=button]') .delay(500) .queue(function(){$(this).hide ...
- Entity Framework 学习初级篇7--基本操作:增加、更新、删除、事务
本节,直接写通过代码来学习.这些基本操作都比较简单,与这些基本操作相关的内容在之前的1至6节基本介绍完毕. l 增加: 方法1:使用AddToXXX(xxx)方法:实例代码如下: ...