結果

問題 No.764 浮動点
ユーザー te-shte-sh
提出日時 2018-12-13 15:00:22
言語 D
(dmd 2.105.2)
結果
WA  
実行時間 -
コード長 1,717 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 153,644 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 21:40:09
合計ジャッジ時間 2,999 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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 readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n; readV(n);
  real[] l; readC(n+2, l);

  auto l0 = l[0], lc = l.cumulativeSum;
  auto ll = new real[](n+2), lr = new real[](n+2);
  ll[1] = l[1];
  foreach (i; 2..n+2) ll[i] = max(ll[i-1], l[i]);
  lr[n+1] = l[n+1];
  foreach_reverse (i; 1..n+1) lr[i] = max(lr[i+1], l[i]);

  auto integral(real a, real x)
  {
    if ((a-x).abs < 1e-11) return 0.0;
    return x*sqrt(a^^2-x^^2) + a^^2*asin(x/a);
  }

  auto calc(real r1, real r2)
  {
    if (r1+r2 < l0) {
      return 0.0;
    } else if (r1+l0 < r2) {
      return PI*r1^^2;
    } else if (r2+l0 < r1) {
      return PI*r2^^2;
    } else {
      auto x = (l0^^2+r1^^2-r2^^2)/(l0*2);
      return integral(r2, x-l0)-integral(r2, -r2)+integral(r1, r1)-integral(r1, x);
    }
  }

  writeln(0);
  foreach (i; 2..n) {
    auto a = lc[1..i+1], b = max(2*ll[i]-a, 0);
    auto c = lc[i+1..$], d = max(2*lr[i+1]-c, 0);

    auto s = calc(a, c)-calc(a, d)-calc(b, c)+calc(b, d);
    writefln("%.7f", s);
  }
  writeln(0);
}

class CumulativeSum(T)
{
  size_t n;
  T[] s;

  this(T[] a)
  {
    n = a.length;
    s = new T[](n+1);
    s[0] = T(0);
    foreach (i; 0..n) s[i+1] = s[i] + a[i];
  }

  T opSlice(size_t l, size_t r) { return s[r]-s[l]; }
  size_t opDollar() { return n; }
}
auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); }
0