首页 > 学院 > 开发设计 > 正文

UVA, 369 conbinations

2019-11-06 07:14:51
字体:
来源:转载
供稿:网友

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<cstdio>

#include<iostream>

#include<math.h>

using namespacestd;

int main(){

    double a,b;

    a = b = 0;

    while(scanf("%lf %lf",&a,&b) && !((a ==0) && (b == 0))){

        double c,d;

        c = d = 1.0;

        int i ,j ;

        for(i = a; i > a - b; i--)

            c = c * (double)i;

        for(j = b; j >=1; j --)

            d = d * (double)j;

        PRintf("%.0lf things taken %.0lf at a time is %.0lf exactly./n",a,b,c/d);

        

    }

    return0;

}

1 刚开始自己没有想出来,后来看了别人的思路发现,给的100!也不过一百多位,而double可以支持三百多位(float32位),所以可以偷懒直接算

2 printf时double为lf

3 double在* 一个int时。要对int强制转换


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表