| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:有两个问题我想请教: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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator