Rasheda And The Zeriba Gym - 100283A ? 计算几何

Posted stupid_one

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Rasheda And The Zeriba Gym - 100283A ? 计算几何相关的知识,希望对你有一定的参考价值。

http://codeforces.com/gym/100283/problem/A

考虑到多边形是不稳定的,是可以变来变去的。

那么总是可以把每个点放到圆上。

所以只需要判断圆心角是不是小于等于360即可。

技术分享
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define ios ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL;


#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <bitset>
const int maxn = 1000 + 20;
int a[maxn];
const double eps = 1e-6;
int n;
double pi = acos(-1.0);
bool check(double r) {
    double res = 0;
    for (int i = 1; i <= n; ++i) {
        res += asin(a[i] / 2.0 / r);
    }
    return res <= pi;
}
void work() {
    int sum = 0;
    int mx = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        mx = max(a[i], mx);
        sum += a[i];
    }
    static int f = 0;
    printf("Case %d: ", ++f);
    if (sum - mx <= mx) {
        cout << "can‘t form a convex polygon" << endl;
        return;
    }
    double be = 0, en = 3e6 + 20;
    while (be + eps < en) {
        double mid = (be + en) / 2;
        if (check(mid)) {
            en = mid;
        } else be = mid;
    }
    printf("%.4f\n", en);
}

int main() {
#ifdef local
    freopen("data.txt", "r", stdin);
//    freopen("data.txt", "w", stdout);
#endif
    freopen("zeriba.in", "r", stdin);
    int t;
    scanf("%d", &t);
    while (t--) work();
    return 0;
}
View Code

 

以上是关于Rasheda And The Zeriba Gym - 100283A ? 计算几何的主要内容,如果未能解决你的问题,请参考以下文章

The plan have to be adjust ...

The Princess and the Pea,摘自iOS应用Snow White and more stories

Lesson 8 The best and the worst

Use the PDFs below or the HTML contents to the left to install and configure P6 EPPM and its additio

[React + Mobx] Mobx and React intro: syncing the UI with the app state using observable and observer

the book for communication or sharing the gratitude and the video website