题意:格路问题 没什么难度 难点在于如何快速计算相对较大的组合数

思路:运用手写计算组合数的方式进行计算  如c(8,3) 如果手算就是   8*7*6/(3*2*1)这样可以很快得解出

计算代码为:(精度没问题? 反正能过)

 u c(u n,u m){
u a=n+m;
u b=min(n,m);
double ans=;
while(b>){
ans*=(1.0*a--)/(1.0*b--);
}
ans+=0.5;//四舍五入
return u(ans);
}

AC代码:

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
const int maxn=;
typedef unsigned u;
u c(u n,u m){
u a=n+m;
u b=min(n,m);
double ans=;
while(b>){
ans*=(1.0*a--)/(1.0*b--);
}
ans+=0.5;
return u(ans);
}
int main(){ u a,b;
while(scanf("%u%u",&a,&b)==){
if(!a&&!b)break;
printf("%u\n",c(a,b));
}
return ;
}

Paths on a Grid POJ - 1942 组合数学 (组合数的快速计算)的更多相关文章

  1. Paths on a Grid(poj 1942)

    给定一个矩形网格的长m和高n,其中m和n都是unsigned int32类型,一格代表一个单位,就是一步,求从左下角到右上角有多少种走法,每步只能向上或者向右走. //注意循环的时候,要循环小的数,否 ...

  2. Paths on a Grid POJ - 1942 排列组合

    题意: 从左下角移动到右上角.每次只能向上或者向右移动一格.问移动的轨迹形成的右半边图形有多少种 题解: 注意,这个图形就根本不会重复,那就是n*m的图形,向上移动n次,向右移动m次. 从左下角移动到 ...

  3. [ACM] POJ 1942 Paths on a Grid (组合)

    Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21297   Accepted: 5212 ...

  4. POJ 1942:Paths on a Grid

    Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 22918   Accepted: 5651 ...

  5. POJ1942——Paths on a Grid(组合数学)

    Paths on a Grid DescriptionImagine you are attending your math lesson at school. Once again, you are ...

  6. Paths on a Grid(简单组合数学)

    Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683 Desc ...

  7. poj1942 Paths on a Grid(无mod大组合数)

    poj1942 Paths on a Grid 题意:给定一个长m高n$(n,m \in unsigned 32-bit)$的矩形,问有几种走法.$n=m=0$时终止. 显然的$C(m+n,n)$ 但 ...

  8. Paths on a Grid(规律)

    Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 23270   Accepted: 5735 ...

  9. Milking Grid POJ - 2185 || 最小覆盖子串

    Milking Grid POJ - 2185 最小覆盖子串: 最小覆盖子串(串尾多一小段时,用前缀覆盖)长度为n-next[n](n-pre[n]),n为串长. 当n%(n-next[n])==0时 ...

随机推荐

  1. Windows 10 配置Linux及安装Docker

    https://baijiahao.baidu.com/s?id=1607159570058814753&wfr=spider&for=pc https://blog.csdn.net ...

  2. Windows Community Toolkit 3.0 - Gaze Interaction

    概述 Gaze Input & Tracking - 也就是视觉输入和跟踪,是一种和鼠标/触摸屏输入非常不一样的交互方式,利用人类眼球的识别和眼球方向角度的跟踪,来判断人眼的目标和意图,从而非 ...

  3. Python_复习_34

    +# 函数 —— 2天 # 函数的定义和调用 # def 函数名(形参): #函数体 #return 返回值 #调用 函数名(实参) # 站在形参的角度上 : 位置参数,*args,默认参数(陷阱), ...

  4. H5 22-通配符选择器

    22-通配符选择器 我是标题 我是段落 我是超链接 --> 我是标题 我是段落 我是超链接 <!DOCTYPE html> <html lang="en"& ...

  5. MyBatis使用注解开发

  6. Migrate MySQL database using dump and restore

    kaorimatz/mysqldump-loader: Load a MySQL dump file using LOAD DATA INFILEhttps://github.com/kaorimat ...

  7. withRouter使用

    import React from 'react'; import {Switch,NavLink,Route,Redirect,withRouter} from 'react-router-dom' ...

  8. Oracle 创建外部表

    Oracle 外部表能迅速的将海量的数据导入到数据库里面,外部表的创建使用步骤如下: 1 创建一个Directory:必须用sys用户创建,用户存放外部数据文件. create directory D ...

  9. 【开讲啦】20181029 oracle教学笔记

    --创建表空间 create tablespace waterboss--表空间名称 datafile 'd:\waterboss.dbf'--用于设置物理文件名称 size 100m--用于设置表空 ...

  10. tensorflow实现基于LSTM的文本分类方法

    tensorflow实现基于LSTM的文本分类方法 作者:u010223750 引言 学习一段时间的tensor flow之后,想找个项目试试手,然后想起了之前在看Theano教程中的一个文本分类的实 ...