結果
問題 | No.764 浮動点 |
ユーザー |
|
提出日時 | 2018-12-13 19:01:30 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 15 ms / 1,500 ms |
コード長 | 1,672 bytes |
コンパイル時間 | 2,670 ms |
コンパイル使用メモリ | 159,780 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 02:20:22 |
合計ジャッジ時間 | 3,665 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;import std.typecons, std.range, std.random, std.math, std.container;import std.numeric, std.bigint, core.bitop, core.stdc.string;struct Circle {real x;real y;real r;}real intersection(Circle c1, Circle c2) {if (c1.r > c2.r) {swap(c1, c2);}real d = sqrt((c1.x - c2.x)^^2 + (c1.y - c2.y)^^2);if (d >= c1.r + c2.r) {return 0;}if (d <= c2.r-c1.r) {return c1.r * c1.r * PI;}real a1 = c1.r * c1.r * acos((d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d * c1.r));real a2 = c2.r * c2.r * acos((d * d + c2.r * c2.r - c1.r * c1.r) / (2 * d * c2.r));real a3 = 0.5 * sqrt((-d + c1.r + c2.r) * (d + c1.r - c2.r) * (d - c1.r + c2.r) * (d + c1.r + c2.r));return a1 + a2 - a3;}real calc(Circle big1, Circle small1, Circle big2, Circle small2) {real a1 = intersection(big1, big2);real a2 = intersection(small1, big2);real a3 = intersection(small2, big1);real a4 = intersection(small1, small2);return (a1 - a2 - a3 + a4);}void main() {auto N = readln.chomp.to!int;auto P = readln.chomp.to!long;auto L = (N+1).iota.map!(_ => readln.chomp.to!long).array;foreach (i; 0..N) {auto s1 = L[0..i+1].sum;auto m1 = L[0..i+1].reduce!max;auto s2 = L[i+1..$].sum;auto m2 = L[i+1..$].reduce!max;auto big1 = Circle(0, 0, s1);auto small1 = Circle(0, 0, max(0, m1*2-s1));auto big2 = Circle(P, 0, s2);auto small2 = Circle(P, 0, max(0, m2*2-s2));writefln("%.9f", calc(big1, small1, big2, small2));}}