题意:第一行给出一个数n,下面n行是n个点的坐标,求出以原点为圆心,覆盖所有坐标的最小角度
链接:http://codeforces.com/problemset/problem/257/C
思路:以原点为圆心按角度排序,求出相邻两点之间的最大角度max,最小角度为360-max
注意点:第一点与最后一点之间需要特判
以下为AC代码:
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | ||
---|---|---|---|---|---|---|---|---|---|---|
10041611 | Practice: luminous11 | 257C - 18 | GNU C++11 | Accepted | 1746 ms | 2080 KB | 2015-02-27 11:06:39 | 2015-02-27 11:06:39 |
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <deque>
#include <list>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#define ll long long
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define read(f) freopen(f, "r", stdin)
#define write(f) freopen(f, "w", stdout)
using namespace std;
const double pi = acos(-1);
bool cmp ( const double &a, const double &b ){
return a < b;
}
int main()
{
ios::sync_with_stdio( false );
int t;
while ( cin >> t ){
vector<double> ang;
double a, b;
for ( int i = 0; i < t; i ++ ){
cin >> a >> b;
double sqr = sqrt( a * a + b * b );
double tmp = asin ( b / sqr ) * 180.0 / pi;
if ( a < 1e-6 ){
tmp = 180 - tmp;
}
ang.pb ( tmp );
}
sort ( all(ang) );
double _max = 360.0 - ang[ang.size()-1] + ang[0];
for ( int i = 1; i < ang.size(); i ++ ){
_max = max ( _max, ang[i] - ang[i-1] );
}
cout << fixed << setprecision(10) << 360.0 - _max << endl;
}
return 0;
}