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

Re:用double不行啊,谁用double AC了 给我看看?

Posted by nan5515522 at 2014-06-10 22:26:36 on Problem 2249
In Reply To:用double不行啊,谁用double AC了 给我看看? Posted by:hongxingxiaonan at 2012-06-11 17:20:28
用double,不用任何技巧算法之类的0ms水过看看哈!


#include<iostream>
#include<Cstdio>
#include<string>
using namespace std;

double cal(double x1, double x2)
{
	double res1 = 1, tmp1 = x1 ,tmp2 = 1, lim2, lim1;
	if(x1 > 2 * x2 + 0.1)
	{
		lim1 = x1 - x2 + 0.9;
		lim2 = x2 + 0.01;
		
	}
	else 
	{
		lim1 = x2 + 0.9;
		lim2 = x1 - x2 + 0.01;
	}

	while(tmp1 > lim1)
	{
		res1 = tmp1 * res1;
		tmp1 = tmp1 - 1;
		if(tmp2 < lim2)
		{
			res1 = res1 / tmp2;
			tmp2 = tmp2 + 1;
		}
	}
	while(tmp2 < lim2)
	{
		res1 = res1 / tmp2;
		tmp2 = tmp2 + 1;
	}
	

	
	return res1;
}


int main()
{
	double a1, a2;
	long long result;
	while(1)
	{
		cin >> a1 >> a2;
		if(a1 < 0.5 && a2 < 0.5)
			break;
		result = (long long)cal(a1, a2);
		cout << result << endl;
	}
	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