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:

  1. #include <iostream>
  2. #include<string.h>
  3. using namespace std;
  4. const int mod = 10000003;
  5. const int N = 1005;
  6. int C[N][N];
  7. void Init ()
  8. {
  9. int i,j;
  10. for (i=1;i<=1004;i++)
  11. {
  12. C[i][0]=C[i][i]=1;
  13. C[i][1] = i;
  14. for (j=1;j<i;j++)
  15. if(C[i][j]==0)
  16. C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
  17. }
  18. }
  19. int main()
  20. {
  21. int c,m,n;
  22. memset(C,0,sizeof(C));
  23. Init();
  24. cin>>c;
  25. while(c--)
  26. {
  27. cin>>m>>n;
  28. if(m==n||n==0)
  29. cout<<1<<endl;
  30. else
  31. cout<<C[m][n]<<endl;
  32. }
  33. return 0;
  34. }
  35.  
  36. /**************************************
  37. Problem id : SDUT OJ 2164
  38. User name : CY_
  39. Result : Accepted
  40. Take Memory : 4408K
  41. Take Time : 20MS
  42. Submit Time : 2014-04-20 11:15:09
  43. **************************************/

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. CodeForces 540D--Bad Luck Island(概率DP)

    貌似竟然是我的第一道概率DP.. 手机码代码真不舒服.... /************************************************ Memory: 67248 KB Ti ...

  2. Altium Designer 多通道设计

    转chenzelin2009的csdn博客:http://blog.csdn.net/chenzelin2009/article/details/5751251# Altium Designer的多图 ...

  3. java 日志技术汇总(log4j , Commons-logging,.....)

    前言 在Tomcat 与weblogic 中的 日志(log4j) 配置系列一 在系列一 中, 有一个问题一直没有解决,就是部署到weblogic 中应用程序如何通过log4j写日志到文件中? 这里仅 ...

  4. 在 windows 上面安装 tensorflow

    这个是 tensorflow 官网地址, https://www.tensorflow.org/get_started/os_setup#pip_installation_on_windows 上面有 ...

  5. php排序之快速排序

    关于快速排序的介绍 请看百度百科讲解的很详细 http://baike.baidu.com/link?url=1VOpp4qjdwKma81MFPozjvyPy2rYJos6ZmfP5Ady3xjEP ...

  6. 杭电ACM1218——Blurred Vision

    题目有点长,并且比較难懂.看了非常久.也看的不是非常懂,仅仅知道输入输出的格式. 直到看了最后的一句话,也就是output那里的最后一句话,题目的意思就非常明白了,就是输出的每个点的像素是原始的四个像 ...

  7. C++ CheckListBox

    实现过程 CCheckListBox    listbox1;     listbox1.AddString("葡萄");     listbox1.AddString(" ...

  8. 分布式助手Zookeeper(四)

    分布式助手Zookeeper(四)博客分类: Zookeeper zookeeper配置同步zookeeper编程 Zookeeper是分布式环境下一个重要的组件,因为它能在分布式环境下,给我带来很多 ...

  9. android112 c代码打印日志,c反编译调用java

    activity: package com.itheima.ccalljava; import android.os.Bundle; import android.app.Activity; impo ...

  10. android开发入门经验 ADT Bundle环境搭建

    现在有许多做开发的转做移动端开发,做J2EE的转做Android开发,我也把自己的一些入门经验与大家分享一下,希望能给你带来帮助. 工具/原料 JDK,ADT,JAVA 方法/步骤   开发工具的准备 ...