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

wa的不是取余的原因

Posted by wjwjw at 2011-06-25 16:51:10 on Problem 2249
用了double才过的,而且去掉取余更快
16MS
double Com(int n, int k)
{
	double a=1,b=1;  
	while(k)
	{
		b*=k--;
		a*=n--;
		if((int)a % (int)b == 0)
			a /= b, b = 1; 
	}
	return a/b;
}
0MS
double Com(int n, int k)
{
	double a=1,b=1;  
	while(k)
	{
		b*=k--;
		a*=n--;
	}
	return a/b;
}
应该是强制转换的原因吧囧

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