POJ 1942 Paths on a Grid(组合数)】的更多相关文章

Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21297   Accepted: 5212 Description Imagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastere…
http://poj.org/problem?id=1942 题意 :在一个n*m的矩形上有n*m个网格,从左下角的网格划到右上角的网格,沿着边画,只能向上或向右走,问有多少条不重复的路 . 思路 :这种问题记得高中的时候就做过,学组合数的时候讲的,反正就是向上向右走,加起来要走的路必定为n+m条,选择n条向上,必定剩下的m为向右的,所以这个题就转化求C(n,m+n),或者是C(m,m+n),不过个人建议用m,n中小的那个数去做,因为省时.因为这个数据较大,所以求组合的时候就要注意以防超时,如果…
// n*m 的格子 从左下角走到右上角的种数// 相当于从 n+m 的步数中选 m 步往上走// C(n+m,m) #include <iostream> #include <string> #include<sstream> #include <cmath> #include <map> #include <stdio.h> #include <string.h> #include <algorithm>…
题目:http://poj.org/problem?id=1942 题意:给定一个矩形网格的长m和高n,其中m和n都是unsigned int32类型,一格代表一个单位,就是一步,求从左下角到右上角有多少种走法,每步只能向上或者向右走 题解:就是 上和 右的排列. 用c(m,n)=n!/m!*(n-m)!; 最重要的是算阶乘. #include<iostream> #include<cstring> #include<cstdio> using namespace st…
Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 22918   Accepted: 5651 Description Imagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastere…
poj1942 Paths on a Grid 题意:给定一个长m高n$(n,m \in unsigned 32-bit)$的矩形,问有几种走法.$n=m=0$时终止. 显然的$C(m+n,n)$ 但是没有取模,n,m的范围又在unsigned int 范围内 于是有一种神奇的方法↓↓ typedef unsigned us;us C(us a,us b){//C(a,b) double cnt=1.0; while(b) cnt*=(double)(a--)/(double)(b--); re…
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683 Description Imagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastered ye…
Paths on a Grid DescriptionImagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastered years ago (this time he's explaining that (a+b)2=a2+2ab+b2). So you decide to waste…
Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 23270   Accepted: 5735 Description Imagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastere…
poj——3177Redundant Paths      洛谷—— P2860 [USACO06JAN]冗余路径Redundant Paths Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15272   Accepted: 6436 Description In order to get from one of the F (1 <= F <= 5,000) grazing fields (which are nu…