結果

問題 No.456 Millions of Submits!
ユーザー はむ吉🐹はむ吉🐹
提出日時 2017-01-02 21:26:37
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 675 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 157,992 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-03 00:22:35
合計ジャッジ時間 8,073 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(19): Deprecation: template `std.math.operations.approxEqual(T, U, V)(T value, U reference, V maxRelDiff = 0.01, V maxAbsDiff = 1e-05)` is deprecated - approxEqual will be removed in 2.106.0. Please use isClose instead.
Main.d(33):        instantiated from here: `solveEquation!real`
Main.d(21): Deprecation: template `std.math.operations.approxEqual(T, U, V)(T value, U reference, V maxRelDiff = 0.01, V maxAbsDiff = 1e-05)` is deprecated - approxEqual will be removed in 2.106.0. Please use isClose instead.
Main.d(33):        instantiated from here: `solveEquation!real`

ソースコード

diff #

import std.algorithm.iteration;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;


const real EPS = 1e-9;


T lambertW(T)(T x, T tol=EPS) {
	auto f = (T t) => t * exp(t) - x;
	return findRoot(f, -1.0f, 10f);
}


T solveEquation(T)(T a, T b, T t, T tol=EPS){
	if (approxEqual(a, 0, EPS)){
		return exp(pow(t, 1 / b));
	} else if (approxEqual(b, 0, EPS)) {
		return pow(t, 1 / a);
	} else {
		return exp(b / a * lambertW(a / b * pow(t, 1 / b)));
	}
}


void main(){
	auto m = readln.chomp.to!int;
	foreach (i; 0..m) {
		auto s = readln.split.map!(to!real);
		auto res = solveEquation(s[0], s[1], s[2]);
		writefln("%.11f\n", res);
	}
}
0