组合数学题。好难啊,请教了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的更多相关文章

  1. 51Nod 1268 和为K的组合

    51Nod  1268  和为K的组合 1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 给出N个正整数组成的数组A,求能否从中选出若干个,使 ...

  2. cdoj 1489 老司机采花

    地址:http://acm.uestc.edu.cn/#/problem/show/1489 题目: 老司机采花 Time Limit: 3000/1000MS (Java/Others)     M ...

  3. ural 1268. Little Chu

    1268. Little Chu Time limit: 0.25 secondMemory limit: 64 MB The favorite occupation of Little Chu is ...

  4. CCPC2017湘潭 1263 1264 1267 1268

    1263 拉升一下就A了 #include <iostream> #include <vector> #include <algorithm> #include & ...

  5. 51Nod:1268 和为K的组合

    1268 和为K的组合  基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题  收藏  关注 给出N个正整数组成的数组A,求能否从中选出若干个,使他们的和为K.如果可以 ...

  6. 1268 和为K的组合 Meet in mid二分思路

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1268&judgeId=193772 给出n = 20个数,问其是 ...

  7. CDOJ 1324 卿学姐与公主(分块)

    CDOJ 1324 卿学姐与公主(分块) 传送门: UESTC Online Judgehttp://acm.uestc.edu.cn/#/problem/show/1324 某日,百无聊赖的卿学姐打 ...

  8. CDOJ 1330 柱爷与远古法阵(高斯消元)

    CDOJ 1330 柱爷与远古法阵(高斯消元) 柱爷与远古法阵 Time Limit: 125/125MS (Java/Others)     Memory Limit: 240000/240000K ...

  9. 51nod 1268 和为K的组合 dfs

    题目: 1268 和为K的组合 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 给出N个正整数组成的数组A,求能否从中选出若干个,使他们的和为K.如果可以,输出:& ...

随机推荐

  1. Spring Boot 系列教程16-数据国际化

    internationalization(i18n) 国际化(internationalization)是设计和制造容易适应不同区域要求的产品的一种方式. 它要求从产品中抽离所有地域语言,国家/地区和 ...

  2. HDU 2802 F(N) 数论+打表

    题目大意:f[n]-n^3=f[n-2]-(n-1)^3 (n >=3),f[1]=1,f[2]=7,求f[n]. 题目思路:将n^3移到到等式右边化简的到:f[n]=f[n-2]+3n*(n- ...

  3. python解析XML之ElementTree

    #coding=utf-8 from xml.etree import ElementTree as ET tree=ET.parse('test.xml') root = tree.getroot( ...

  4. property函数

    __metaclass__=type class Rectangle:     def __init__(self):             self.width=0             sel ...

  5. js滚动条

    /*滚动条在Y轴上的滚动距离*/function ScrollTop(){ var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0; i ...

  6. SDAU课程练习--problemQ(1016)

    题目描述 FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'med ...

  7. socket常见几种异常

    第1个异常是 java.net.BindException:Address already in use: JVM_Bind. 该异常发生在服务器端进行newServerSocket(port)(po ...

  8. CodeForces 429 B B. Working out

    Description Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to loo ...

  9. POJ 2289 Jamie's Contact Groups

    二分答案+网络最大流 #include<cstdio> #include<cstring> #include<cmath> #include<vector&g ...

  10. index.do为后缀的是什么开发语言? 有什么技术特点?

    @Override 重写父类的方法.@Nullable 表示定义的字段可以为空. 一般情况下扩展名可以体现出一个网站使用的技术,***.html?id=***,这个就是普通的html页面,然后通过ja ...