Binomial Coeffcients

TimeLimit:
1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

输入

输出

示例输入

3

1 1

10 2

954 723

示例输出

1

45

3557658

/*******************

组合数学

组合数 用 递推  :组合数公式 C[n][m] = C[n-1][m-1] + C[n-1][m]

************************/

Code:

#include <iostream>
#include<string.h>
using namespace std;
const int mod = 10000003;
const int N = 1005;
int C[N][N];
void Init ()
{
int i,j;
for (i=1;i<=1004;i++)
{
C[i][0]=C[i][i]=1;
C[i][1] = i;
for (j=1;j<i;j++)
if(C[i][j]==0)
C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
}
}
int main()
{
int c,m,n;
memset(C,0,sizeof(C));
Init();
cin>>c;
while(c--)
{
cin>>m>>n;
if(m==n||n==0)
cout<<1<<endl;
else
cout<<C[m][n]<<endl;
}
return 0;
} /**************************************
Problem id : SDUT OJ 2164
User name : CY_
Result : Accepted
Take Memory : 4408K
Take Time : 20MS
Submit Time : 2014-04-20 11:15:09
**************************************/

Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)的更多相关文章

  1. Sdut 2165 Crack Mathmen(数论)(山东省ACM第二届省赛E 题)

    Crack Mathmen TimeLimit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Since mathmen take security ...

  2. ACM Sdut 2158 Hello World!(数学题,排序) (山东省ACM第一届省赛C题)

    题目描述 We know thatIvan gives Saya three problems to solve (Problem F), and this is the firstproblem. ...

  3. Sdut 2151 Phone Numbers (山东省ACM第一届省赛题 A)

    题目描述 We know thatif a phone number A is another phone number B's prefix, B is not able to becalled. ...

  4. 山东省第七届省赛 D题:Swiss-system tournament(归并排序)

    Description A Swiss-system tournament is a tournament which uses a non-elimination format. The first ...

  5. 山东省第六届省赛 H题:Square Number

    Description In mathematics, a square number is an integer that is the square of an integer. In other ...

  6. Binomial Coeffcients 历届山东省省赛题

    Binomial Coeffcients Time Limit: 1000MS Memory limit: 65536K 题目描述   输入   输出   示例输入 3 1 1 10 2 954 72 ...

  7. Binomial Coeffcients 过去山东省省赛冠军

    Binomial Coeffcients Time Limit: 1000MS Memory limit: 65536K 题目描写叙述   输入   输出   演示样例输入 3 1 1 10 2 95 ...

  8. 2013 ACM/ICPC 长春网络赛F题

    题意:两个人轮流说数字,第一个人可以说区间[1~k]中的一个,之后每次每人都可以说一个比前一个人所说数字大一点的数字,相邻两次数字只差在区间[1~k].谁先>=N,谁输.问最后是第一个人赢还是第 ...

  9. 第二届强网杯部分题writeup

    0x00 题目名称 签到 操作内容:   FLAG值: flag{welcome_to_qwb} 0x01 题目名称 Weclome 操作内容: 通过查看文件发现是一个bmp格式的图片文件,然后加上后 ...

随机推荐

  1. dut1305 台阶

    Description 如上图所示的一个台阶他的积水量是4 + 2 + 4 + 3 + 4 = 17. 给你一个长度是n的台阶.告诉你每个台阶的高度,求积水量是多少? Input 多组输入数据: 每组 ...

  2. 高密度Java应用部署的一些实践

    传统的Java应用部署模式,一般遵循“硬件->操作系统->JVM->Java应用”这种自底向上的部署结构,其中JEE应用可以细化为“硬件->操作系统->JVM->J ...

  3. mongdb高级操作(group by )

    首先介绍哈方法 /** * 利用java驱动自带函数分组查询 * @param key 用来分组文档的字段 [group by key] * @param cond 执行过滤的条件 [where na ...

  4. js基础一

    1.声明提升:变量的声明提升,函数的声明提升,但函数赋值表达式不会提升: foo(); // 正常运行,因为foo在代码运行前已经被创建 function foo() {} foo(); // 出错: ...

  5. 使用ProcDump在程序没有响应时自动收集dump

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:使用ProcDump在程序没有响应时自动收集dump.

  6. C#编译器怎么检查代码是否会执行

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:C#编译器怎么检查代码是否会执行.

  7. 如何用Java进行3DES加密解

    原文地址: http://weavesky.com/2008/01/05/java-3des/ 最近一个合作商提出使用3DES交换数据,本来他们有现成的代码,可惜只有.net版本,我们的服务器都是Li ...

  8. linux环境下tcpdump源代码分析

    Linux 环境下tcpdump 源代码分析 韩大卫@吉林师范大学 tcpdump.c 是tcpdump 工具的main.c, 本文旨对tcpdump的框架有简单了解,只展示linux平台使用的一部分 ...

  9. iOS设计模式之生成器

    iOS设计模式之生成器 1.生成器模式的定义 (1): 将一个复杂的对象的构件与它的表示分离,使得相同的构建过程能够创建不同的表示 (2): 生成器模式除了客户之外还包括一个Director(指导者) ...

  10. Error: no `server' JVM at...解决办法 【转】

    出现问题:用java -jar XXX.jar -server -Xms900m -Xmx900m 提示错误Error: no `server' JVM at `C:\Program Files\Ja ...