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格式的图片文件,然后加上后 ...
随机推荐
- HW2.21
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- linux bin文件制作
一 Linux安装文件 Linux常见的安装为tar,zip,gz,rpm,deb,bin等.我们可以简单的分为三类, 第一:打包或压缩文件tar,zip,gz等,一般解压后即可,或者解压后运行sh文 ...
- 用lambda构建ORM查询语句
本文介绍如何解析lambda表达式来获取一个满足条件的查询语句. 先看个截图 通过设置实体对象Article_Content的查询表达式,就可以获取对应的参数化SQL语句,使用起来很方便,减少了代码 ...
- Fast特征检测
一.Fast算法 1.基本原理 Fast特征点检测feature2D原理是在圆周上按顺时针方向从1到16的顺序对圆周像素点进行编号.如果在圆周上有N个连续的像素的亮度都比圆心像素的亮度Ip加上阈值t还 ...
- URAL 1992 CVS 链表
不更改链表结构,只是添加节点,没有删除节点.通过记录和更改标记来模拟题意的插入和删除,复制 指针模拟链表: 预开指针,存在M[]中,可以提高效率 #include<functional> ...
- RSS实例文档
<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0&quo ...
- C语言中怎么求动态数组大小
先来个简单的样例 int a[] = {1,2,3}; int arr_len = 0; arr_len = sizeof(a)/sizeof(int); 解释:sizeof() keyword是求出 ...
- nginx 安装手记 分类: Nginx 服务器搭建 2015-07-14 14:28 15人阅读 评论(0) 收藏
Nginx需要依赖下面3个包 gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ ) zlib-1.2.8.tar.gz rewrite 模块需要 pcre 库 ( ...
- xargs i I{} 参数说明
find . -type f | xargs -I{} md5sum {} find . -type f -name "*.txt" | xargs -i cp {} /tmp/k ...
- [TypeScript] 1. Catching JavaScript Mistakes with TypeScript
The TypeScript compiler is a powerful tool which catches mistakes even in vanilla JavaScript. Try it ...