- 隐形的翅膀
- 2017-07-04 16:43:21 @
#include<cstdio>
#include<iostream>
#include<algorithm>
#define gold 0.6180339887498949
#define MAXN 30010
using namespace std;
int n,a[MAXN],Lx,Ry;
double minn=1000000.0;
inline void read(int&x) {
x=0;int f=1;char c=getchar();
while(c>'9'||c<'0') {if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-48;c=getchar();}
x=x*f;
}
inline bool cmp(int a,int b) {
return a<b;
}
inline double abs(double x) {
if(x<0) return -x;
return x;
}
int main() {
read(n);
for(int i=1;i<=n;i++) read(a[i]);
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++) {
if(a[i]==0) continue;
double p=a[i]/gold;
/*int l=i+1,r=n,mid;
while(l<r) {
mid=(l+r)>>1;
if(a[mid]>p) r=mid-1;
else l=mid+1;
}*/
int k=lower_bound(a+1,a+1+n,p)-a-1;
if(a[k]==0) continue;
if(abs(a[k]-p)<minn) {
minn=abs(a[k]-p);
Lx=a[i];
Ry=a[k];
}
}
printf("%d\n%d\n",Lx,Ry);
return 0;
}
0 条评论
目前还没有评论...