#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<cstdio>
#include<iostream>
#include<math.h>
using namespace std;
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);
}
return 0;
}
1 刚开始自己没有想出来,后来看了别人的思路发现,给的100!也不过一百多位,而double可以支持三百多位(float32位),所以可以偷懒直接算
2 printf时double为lf
3 double在* 一个int时。要对int强制转换