結果

問題 No.456 Millions of Submits!
ユーザー te-shte-sh
提出日時 2017-12-06 13:47:06
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 4,199 ms / 4,500 ms
コード長 889 bytes
コンパイル時間 2,897 ms
コンパイル使用メモリ 160,892 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 17:14:16
合計ジャッジ時間 15,447 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 44 ms
4,376 KB
testcase_10 AC 44 ms
4,376 KB
testcase_11 AC 422 ms
4,376 KB
testcase_12 AC 4,199 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.math;      // math functions
import std.typecons;  // Tuple, Nullable, BigFlags

void main()
{
  auto m = readln.chomp.to!int;
  foreach (_; 0..m) {
    auto rd = readln.splitter;
    auto a = rd.front.to!real; rd.popFront();
    auto b = rd.front.to!real; rd.popFront();
    auto t = rd.front.to!real;

    if (b == 0) {
      writefln("%.10f", t ^^ (1.0L/a));
      continue;
    } else if (a == 0) {
      writefln("%.10f", E ^^ (t ^^ (1.0L/b)));
      continue;
    }

    auto r = a / b * t ^^ (1.0L / b);

    auto calc(real x)
    {
      return x * log(x);
    }

    auto eps = 0, mi = eps, ma = 100;

    auto bsearch = iota(mi, ma, 1.0e-10L).map!(n => tuple(n, calc(n))).assumeSorted!"a[1] < b[1]";
    auto x = bsearch.lowerBound(tuple(0, r)).back[0] + eps;

    writefln("%.10f", x ^^ (b/a));
  }
}
0