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:有两个问题我想请教:

Posted by frkstyc at 2005-05-08 00:10:23 on Problem 1067
In Reply To:Re:有两个问题我想请教: Posted by:dxm at 2005-05-08 00:08:31
直接这样
printf("%d\n", (int)(abs(a-b)*phi)!=min(a,b));
其中phi=1.618...
道理很容易明白吧?

> 谢谢!但为什么我的这个算法不对呢?是不是漏了什么地方?
> #include <iostream>
> #include <cmath>
> using namespace std;
> 
> void main()
> {
> 	int a, b, t;
> 	double h = (sqrt(5) + 1) / 2;
> 
> 	while(cin>>a>>b)
> 	{
> 		if(a < b)
> 		{
> 			t = a / h;
> 			if(t != a / h)
> 				t = t + 1;
> 			if(b == a + t)
> 				cout<<0<<endl;
> 			else
> 				cout<<1<<endl;
> 		}
> 		else
> 		{
> 			t = b / h;
> 			if(t != b / h)
> 				t = t + 1;
> 			if(a == b + t)
> 				cout<<0<<endl;
> 			else
> 				cout<<1<<endl;
> 		}
> 	}
> }

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