Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

怕精度 不够,就用 Double ~~~

Posted by 810974380 at 2009-08-20 11:23:24 on Problem 2249 and last updated at 2009-08-20 11:25:27
支持 Double ~~~~~

810974380 2249 Accepted 168K 0MS C 


#include<stdio.h>
#include<stdlib.h>
double fab(long m,long n)
{ double ans=1,w=1;long i;
  if(n>m/2) n=m-n;
	for(i=n;i>=1;i--)
	{
		w*=(m-n+i);
		if((int)w%i==0) w/=i;
		else ans*=i;
	}
	return w/ans;
}
int main()
{long a,b;
 while(scanf("%ld%ld",&a,&b))
 {if(a==0&&b==0) break;
  printf("%0.f\n",fab(a,b));
 }
 system("pause");
 return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator