結果

問題 No.764 浮動点
ユーザー square1001square1001
提出日時 2019-03-27 21:45:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,607 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 84,120 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 13:47:04
合計ジャッジ時間 1,544 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 5 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 5 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 6 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 6 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 8 ms
5,376 KB
testcase_21 WA -
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 6 ms
5,376 KB
testcase_24 WA -
testcase_25 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const 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);
}
double area(double a, double b, double c) {
	if (a + b <= c) return 0;
	if (a < b) swap(a, b);
	if (a > b + c) return b * b * pi;
	double l = 0, r = min(a, b);
	for (int i = 0; i < 60; ++i) {
		double m = (l + r) * 0.5;
		double x = sqrt(a * a - m * m) + sqrt(b * b - m *m);
		if (x >= c) l = m;
		else r = m;
	}
	double rad1 = asin(l / a);
	double rad2 = asin(l / b);
	double circle1 = rad1 * a * a;
	double circle2 = rad2 * b * b;
	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);
			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;
}
0