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. HDOJ-ACM1016(JAVA) 字典序全排列,并剪枝

    转载声明:原文转自http://www.cnblogs.com/xiezie/p/5576273.html 题意: 一个环是用图中所示的n个圆组成的.把自然数1.2.…….n分别放入每个圆中,并在相邻 ...

  2. 用C语言实现有限状态自动机FSM

    摘要:状态机模式是一种行为模式,在<设计模式>这本书中对其有详细的描述,通过多态实现不同状态的调转行为的确是一种很好的方法,只可惜在嵌入式环境下,有时只能写纯C代码,并且还需要考虑代码的重 ...

  3. 使用sessionStorage得一个坑

    1.首先sessionStorage.setItem("isMybill" false) 2.使用的时候 sessionStorage.getItem('isMybill')  / ...

  4. linux Kernell crash dump------kdump 的安装设置+Linux系统崩溃的修复解决过程+mysql+kvm

    http://www.ibm.com/developerworks/cn/linux/l-cn-dumpanalyse/https://www.kernel.org/pub/linux/utils/k ...

  5. bind的例子

    10.24 给定一个string,使用bind和check_size在一个int的vector中查找第一个大于string长度的值. #include<iostream> #include ...

  6. (原创)speex与wav格式音频文件的互相转换(二)

    之前写过了如何将speex与wav格式的音频互相转换,如果没有看过的请看一下连接 http://www.cnblogs.com/dongweiq/p/4515186.html 虽然自己实现了相关的压缩 ...

  7. Spring MVC 3.0.5+Spring 3.0.5+MyBatis3.0.4全注解实例详解(五)

    这是本系列的最后一篇,主要讲一下FreeMarker模板引擎的基本概念与常用指令的使用方式.     一.FreemMarker基本概念     FreemMarker是一个用Java语言编写的模板引 ...

  8. quartz多个scheduler实现

    1.首先排除错误用法 SchedulerFactory schedulerFactory = new StdSchedulerFactory(); Scheduler scheduler = sche ...

  9. linux下svn服务搭建

    安装svn需要依赖apr和apr-util这两个软件,所以先安装这两个软件 下载安装APR wget http://apache.fayea.com//apr/apr-1.5.2.tar.gz .ta ...

  10. 制作win7+ubuntu +winPE+CDlinux多系统启动U盘

    制作前期准备工作 1.需要软件 grub4dos(http://sourceforge.net/projects/grub4dos/files/) UltraISO(http://cn.ezbsyst ...