fork(1) download
  1. #include<cstdio>
  2. #include<iostream>
  3. #include<algorithm>
  4. #include<cmath>
  5. using namespace std;
  6. const int N=100005;
  7. struct ve{
  8. long double k;
  9. int z;
  10. }a[N];
  11.  
  12. bool cmp(const ve &a,const ve &b)
  13. {
  14. return a.k<b.k;
  15. }
  16.  
  17. int main()
  18. {
  19. int n,i,id1,id2,x,y;
  20. long double mi;
  21. scanf("%d",&n);
  22. for (i=1;i<=n;i++)
  23. scanf("%d%d",&x,&y),a[i].z=i,a[i].k=atan2(y,x);
  24. sort(a+1,a+n+1,cmp);
  25. id1=a[1].z; id2=a[n].z;
  26. mi=a[1].k+2*acos(-1)-a[n].k;
  27. for (i=2;i<=n;i++)
  28. {
  29. long double tmp=a[i].k-a[i-1].k;
  30. if (tmp<mi)
  31. {
  32. mi=tmp;
  33. id1=a[i-1].z;
  34. id2=a[i].z;
  35. }
  36. }
  37. printf("%d %d\n",id1,id2);
  38. }
Success #stdin #stdout 0s 19192KB
stdin
4
-9901 9900
-10000 9899
9899 9801
9899 9900
stdout
1 2