codeforces 257C解题报告
来源:互联网 发布:win10win7共享网络 编辑:程序博客网 时间:2024/06/05 23:05
这破题,开始不知道是算法挂了,和正确答案的差距很小,还以为是精度不够。。题意:有个初始的坐标(0, 0) 然后有n个人的坐标(xi, yi) 你的任务就是求出最小的扇形的角度,覆盖所有的人,扇形r无限大一开始直接atan2(y, x)求出角度,然后加PI排个序,最大减最小输出,wa到死。这题该先存下角度,然后排个序,在枚举最接近的两个点,假设这两个点之间的扇形区域就是我们求的区域的补,那么只需要这个区域最大,答案就最小了
//// Created by Matrix on 2016-01-22// Copyright (c) 2015 Matrix. All rights reserved.//////#pragma comment(linker, "/STACK:102400000,102400000")#include <algorithm>#include <cctype>#include <cmath>#include <cstdio>#include <cstdlib>#include <cstring>#include <iomanip>#include <iostream>#include <map>#include <queue>#include <string>#include <sstream>#include <set>#include <vector>#include <stack>#define ALL(x) x.begin(), x.end()#define INS(x) inserter(x, x,begin())#define ll long long#define CLR(x) memset(x, 0, sizeof x)using namespace std;const int inf = 0x3f3f3f3f;const int MOD = 1e9 + 7;const int maxn = 1e5 + 10;const int maxv = 1e3 + 10;const double eps = 1e-10;const double PI = acos(-1);double x[maxn], y[maxn];double angle[maxn];int main() {#ifdef LOCAL freopen("in.txt", "r", stdin);// freopen("out.txt","w",stdout);#endif ios::sync_with_stdio(0); int n; while(cin >> n) { for(int i = 1; i <= n; i++) { cin >> x[i] >> y[i]; } for(int i = 1; i <= n; i++) { angle[i] = atan2(y[i], x[i]); } sort(angle + 1, angle + 1 + n); double res = 2 * PI; angle[n+1] = angle[1] + 2.0 * PI; for(int i = 1; i <= n; i++) { res = min(res, 2 * PI - fabs(angle[i + 1] - angle[i])); }// printf("%f\n", res); cout << setprecision(10) << res / acos(-1) * 180.0 << endl; } return 0;}
0 0
- codeforces 257C解题报告
- Codeforces 117C解题报告
- CodeForces 173 C. Spiral Maximum 解题报告
- CodeForces 115C. Plumber 解题报告
- codeforces Round #237(div2) C解题报告
- codeforces Round #241(div2) C解题报告
- codeforces Round #269(div2) C解题报告
- codeforces Round #267(div2) C解题报告
- codeforces Round #271(div2) C解题报告
- codeforces Round #272(div2) C解题报告
- codeforces Round #264(div2) C解题报告
- codeforces Round #263(div2) C解题报告
- codeforces Round #273(div2) C解题报告
- codeforces Round #274(div2) C解题报告
- codeforces Round #261(div2) C解题报告
- codeforces Round #260(div2) C解题报告
- codeforces Round #259(div2) C解题报告
- codeforces Round #275(div2) C解题报告
- centos6.5下安装nginx1.8.0
- 批量执行语句之——禁用所有表的外键
- SEAndroid原理分析
- 槽函数的好处
- repeatCount和repeatDuration
- codeforces 257C解题报告
- MAC 10.10.5编译opencv3.0(java版本)
- Android keystore 的MD5、SHA1值获取方法
- 小乔落花流水
- 嵌入式系统学习入门篇之-----开门探头
- 【Web前端】Js利用正则表达式提取字符串
- codeforces 148E
- 蓝桥杯 01背包
- RunLoop学习