結果
問題 | No.724 円と円の間の円 |
ユーザー |
|
提出日時 | 2018-08-24 17:03:15 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,211 bytes |
コンパイル時間 | 2,274 ms |
コンパイル使用メモリ | 164,000 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 01:36:36 |
合計ジャッジ時間 | 3,268 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 WA * 1 |
ソースコード
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;auto rdsp(){return readln.splitter;}void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}void main(){int n; real a, b; readV(n, a, b);auto c = (a+b)/2, d = (a*b).sqrt, eps = 1.0e-7L;struct Cir{real x, y, r;this(real x){this.x = x;y = (d^^2 * (1 - (x-c)^^2/c^^2)).sqrt;r = ((x-a)^^2 + y^^2).sqrt - a;}}Cir e;if (n%2 == 1) {e = Cir(a+b);n = (n-1)/2;} else {auto calc1(real x){auto e = Cir(x);return e.r - e.y;}auto bs = iota(0.0L, a+b, eps).map!(x => tuple(x, calc1(x))).assumeSorted!"a[1]<b[1]";auto x = bs.lowerBound(tuple(0, 0)).back[0];e = Cir(x);n = n/2-1;}auto calc(Cir e, real x2){auto e2 = Cir(x2);return (e2.r+e.r) - ((e2.x-e.x)^^2+(e2.y-e.y)^^2).sqrt;}foreach (_; 0..n) {auto bs = iota(0.0L, e.x, eps).map!(x2 => tuple(x2, calc(e, x2))).assumeSorted!"a[1]<b[1]";auto x2 = bs.lowerBound(tuple(0, 0)).back[0];e = Cir(x2);}writefln("%.6f", e.r);}