結果
| 問題 |
No.764 浮動点
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2019-03-27 22:04:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,500 ms |
| コード長 | 1,945 bytes |
| コンパイル時間 | 769 ms |
| コンパイル使用メモリ | 83,416 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 06:13:21 |
| 合計ジャッジ時間 | 1,971 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long double pi = acos(-1);
pair<int, int> calc(vector<int> v) {
int sum = 0, mx = 0;
for (int i = 0; i < v.size(); ++i) {
sum += v[i];
mx = max(mx, v[i]);
}
int L = 0, R = sum;
if (mx * 2 > sum) L = mx * 2 - sum;
return make_pair(L, R);
}
long double area(long double a, long double b, long double c) {
if (a + b <= c) return 0;
if (a < b) swap(a, b);
if (a > b + c) return b * b * pi;
long double l = 0, r = min(a, b);
if (a * a <= b * b + c * c) {
for (int i = 0; i < 60; ++i) {
long double m = (l + r) * 0.5;
long double x = sqrt(a * a - m * m) + sqrt(b * b - m * m);
if (x >= c) l = m;
else r = m;
}
}
else {
for (int i = 0; i < 60; ++i) {
long double m = (l + r) * 0.5;
long double x = sqrt(a * a - m * m) - sqrt(b * b - m * m);
if (x >= c) r = m;
else l = m;
}
}
long double rad1 = asin(l / a);
long double rad2 = (a * a <= b * b + c * c ? asin(l / b) : pi - asin(l / b));
long double circle1 = rad1 * a * a;
long double circle2 = rad2 * b * b;
long double ans = circle1 + circle2 - c * l;
return ans;
}
int main() {
int N;
cin >> N;
vector<int> A(N + 2);
int sum = 0, mx = 0;
for (int i = 0; i < N + 2; ++i) {
cin >> A[i];
}
cout.precision(15);
pair<int, int> resbase = calc(A);
if (resbase.first > 0) {
for (int i = 0; i < N; ++i) {
cout << 0 << '\n';
}
}
else {
for (int i = 1; i <= N; ++i) {
vector<int> vl, vr;
for (int j = 1; j <= i; ++j) {
vl.push_back(A[j]);
}
for (int j = i + 1; j <= N + 1; ++j) {
vr.push_back(A[j]);
}
pair<int, int> wl = calc(vl);
pair<int, int> wr = calc(vr);
long double ans = 0;
ans += area(wl.second, wr.second, A[0]);
ans += area(wl.first, wr.first, A[0]);
ans -= area(wl.second, wr.first, A[0]);
ans -= area(wl.first, wr.second, A[0]);
cout << ans << '\n';
}
}
return 0;
}
square1001