結果

問題 No.764 浮動点
ユーザー kriiikriii
提出日時 2018-12-12 01:12:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,120 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 40,392 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 22:31:07
合計ジャッジ時間 1,249 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <math.h>

double pi = acos(-1.0);
int N,L[1010];

void dif(int &a1, int &a2, int l)
{
	if (l <= a1) a1 -= l;
	else if (a2 <= l) a1 = l - a2;
	else a1 = 0;
	a2 += l;
}

double ar(long long l, long long r1, long long r2)
{
	if (r1 == 0 || r2 == 0) return 0;
	if (l >= r1 + r2) return 0;
	if (r1 + l <= r2) return r1 * r1 * pi;
	if (r2 + l <= r1) return r2 * r2 * pi;

	double a1 = r1 * r1 * acos((l * l + r1 * r1 - r2 * r2) / (2. * l * r1));
	double a2 = r2 * r2 * acos((l * l + r2 * r2 - r1 * r1) / (2. * l * r2));
	double a3 = sqrt((-l + r1 + r2) * (l - r1 + r2) * (l + r1 - r2) * (l + r1 + r2)) / 2;
	return a1 + a2 - a3;
}

int main()
{
	//scanf ("%d",&N);
	//for (int i=0;i<=N+1;i++) scanf ("%d",&L[i]);
	N = 1000;
	for (int i=0;i<=N+1;i++) L[i] = 1000;

	for (int i=1;i<=N;i++){
		int a1 = L[1], a2 = L[1];
		for (int j=2;j<=i;j++) dif(a1, a2, L[j]);
		int b1 = L[N+1], b2 = L[N+1];
		for (int j=N;j>i;j--) dif(b1, b2, L[j]);

		double ans = 0;
		ans += ar(L[0],a1,b1);
		ans -= ar(L[0],a2,b1);
		ans -= ar(L[0],a1,b2);
		ans += ar(L[0],a2,b2);
		printf ("%.12lf\n",ans);
	}

	return 0;
}
0