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格式的图片文件,然后加上后 ...
随机推荐
- 记一次 Google 面试经历
本文由码农网 – 小峰原创翻译,转载请看清文末的转载要求,欢迎参与我们的付费投稿计划! 这是我上周去面试的地方.很顺利,我觉得——至少我认为我已经尽我所能,并且无论发生什么事情对我都是有帮助的. 由于 ...
- poj 1459 Power Network【建立超级源点,超级汇点】
Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 25514 Accepted: 13287 D ...
- js关键字
这已经是我第二次遇到这个问题了..关于关键字,用来做函数的命名,,,在高清上没问题,标清上秒死...页面都出不来...wtf...做个记录.. js关键字http://www.itxueyuan.or ...
- java.util.Map按照key值合并的value的Collection 集合中。
用java实现把多个map的内容合并的一个resultMap中 代码大致如下 /** * @author Shalf */ public class MapUtil { /** * 把partMa ...
- wxPython 对话框关闭后进程无法退出的原因
wxPython中不要用对话框作为主程序wx.Dialog,这会导致程序关闭后进程无法退出.一种可行的做法是用wx.Frame代替
- JAVA自动生成正则表达式工具类
经过很久的努力,终于完成了JAVA自动生成正则表达式工具类.还记得之前需要正则,老是从网上找吗?找了想修改也不会修改.现在不用再为此烦恼了,使用此生成类轻松搞定所有正则表达式.赶快在同事面前炫一下吧. ...
- SQL Server 2008 游标使用实例
本文使用以下两张数据库表作为演示对象. 1 游标初探--使用游标进行遍历 declare @classAndStudent table( class_id int, --班级ID class_name ...
- [Node.js] Creating JWTs (JSON Web Tokens) in Node
In this lesson we will look at all of the pieces that combine together to create a JWT (j AWT) or JS ...
- 【代码优化】坚持使用Override注解
对于传统程序猿,注解里面最重要的就是Override注解了.这里的注解,都是指仅仅能用在方法中的声明, 她表示被注解的方法用于覆盖了父类的一个声明,假设坚持使用这个注解,能够防止一大类的非法错误. & ...
- dmesg 程序崩溃调试2
dmesg命令基于缓冲区打印信息dmesg -c可以清除该内存信息清除后demsg 命令不显示任何信息,但可以到/var/log/dmesg查看信息 dmesg |tail 20dmesg |head ...