Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)
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 题)的更多相关文章
- Sdut 2165 Crack Mathmen(数论)(山东省ACM第二届省赛E 题)
Crack Mathmen TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take security ...
- ACM Sdut 2158 Hello World!(数学题,排序) (山东省ACM第一届省赛C题)
题目描述 We know thatIvan gives Saya three problems to solve (Problem F), and this is the firstproblem. ...
- 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. ...
- 山东省第七届省赛 D题:Swiss-system tournament(归并排序)
Description A Swiss-system tournament is a tournament which uses a non-elimination format. The first ...
- 山东省第六届省赛 H题:Square Number
Description In mathematics, a square number is an integer that is the square of an integer. In other ...
- Binomial Coeffcients 历届山东省省赛题
Binomial Coeffcients Time Limit: 1000MS Memory limit: 65536K 题目描述 输入 输出 示例输入 3 1 1 10 2 954 72 ...
- Binomial Coeffcients 过去山东省省赛冠军
Binomial Coeffcients Time Limit: 1000MS Memory limit: 65536K 题目描写叙述 输入 输出 演示样例输入 3 1 1 10 2 95 ...
- 2013 ACM/ICPC 长春网络赛F题
题意:两个人轮流说数字,第一个人可以说区间[1~k]中的一个,之后每次每人都可以说一个比前一个人所说数字大一点的数字,相邻两次数字只差在区间[1~k].谁先>=N,谁输.问最后是第一个人赢还是第 ...
- 第二届强网杯部分题writeup
0x00 题目名称 签到 操作内容: FLAG值: flag{welcome_to_qwb} 0x01 题目名称 Weclome 操作内容: 通过查看文件发现是一个bmp格式的图片文件,然后加上后 ...
随机推荐
- c语言之sizeof总结
一.sizeof的概念 Sizeof是C语言的一种单目操作符,如C语言的其他操作符++.--等.它并不是函数.Sizeof操作符以字节形式给出了其操作数的存储大小.操作数可以是一个表达式或括在括号内的 ...
- Hadoop学习记录(4)|MapReduce原理|API操作使用
MapReduce概念 MapReduce是一种分布式计算模型,由谷歌提出,主要用于搜索领域,解决海量数据计算问题. MR由两个阶段组成:Map和Reduce,用户只需要实现map()和reduce( ...
- Codeforces 295C Greg and Friends
BFS+DP.dp[i][j][0]表示有i个50kg,j个100kg的人在左岸,dp[i][j][1]表示有i个50kg,j个100kg的人在右岸.用BFS求最短路的时候记录到达该状态的可能情况. ...
- 源码生成deb包
方法一 源码包要求是使用 automake 进行编译管理的. 安装路径不能指定为 /usr/local 下的目录,否则生成 deb 包期间报错. 制作的工具是 dh-make ,如果没有安装,要先安装 ...
- 问题-delphi XE2 Stack Overflow- save your work and restart CodeGear
问题现象:某一天,启动DLEPHI XE2 后,新建一个工程,双击一个事件,“Stack Overflow- save your work and restart CodeGear delphi xe ...
- jq问题处理
1.同一个事件,点击显示和隐藏 $(document).ready(function(){ $('.container .nav-header').click(function(){ var chan ...
- systemtap 列出所有linux 内核模块与相关函数2
[root@localhost src]# uname -aLinux localhost.localdomain 2.6.32 #1 SMP Sun Sep 20 18:58:21 PDT 2015 ...
- PHP克隆魔术方法
克隆对象 __clone() $p2=clone $p; $p=>say(); 克隆对象的时候自动调用的方法 作用和构造方法一样是对新克隆的对象进行初始化 在这个方法中$this是副本所以可以给 ...
- oracle Form Builer:FIND_FORM Built-in
Description Searches the list of forms and returns a form module ID when it finds a valid form with ...
- 转:ORACLEERP开发基础之EBS开发基础
转自:http://blog.itpub.net/8781091/viewspace-1012244/ [内容导航] 第1页:开发工具安装 第2页:增加数据块 第3页:注册表单FORM 第4页:注册请 ...