結果
| 問題 |
No.450 ベー君のシャトルラン
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-14 09:01:34 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,998 bytes |
| コンパイル時間 | 2,240 ms |
| コンパイル使用メモリ | 80,444 KB |
| 実行使用メモリ | 104,684 KB |
| 最終ジャッジ日時 | 2024-11-25 22:12:05 |
| 合計ジャッジ時間 | 11,318 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 18 TLE * 2 |
ソースコード
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Scanner;
public class Main {
int vl, vr;
int d;
int w;
BigDecimal checkai() {
BigDecimal vl = new BigDecimal(this.vl, MathContext.DECIMAL128);
BigDecimal vr = new BigDecimal(this.vr, MathContext.DECIMAL128);
BigDecimal d = new BigDecimal(this.d, MathContext.DECIMAL128);
BigDecimal w = new BigDecimal(this.w, MathContext.DECIMAL128);
return w.multiply(d).divide(vl.add(vr), MathContext.DECIMAL128);
}
double souteikai() {
double vl = (double) this.vl;
double vr = (double) this.vr;
double d = (double) this.d;
double w = (double) this.w;
return w * d / (vl + vr);
}
double gokai() {
double vl = (double) this.vl;
double vr = (double) this.vr;
double d = (double) this.d;
double w = (double) this.w;
double ans = 0;
while (d > 1e-7) {
double t = d / (w + vr);
ans += w * t;
d -= t * (vl + vr);
double tmp = vr;
vr = vl;
vl = tmp;
}
return ans;
}
void run() {
vl = sc.nextInt();
vr = sc.nextInt();
d = sc.nextInt();
w = sc.nextInt();
assert (1 <= vl && vl <= 1_000_000_000L);
assert (1 <= vr && vr <= 1_000_000_000L);
assert (1 <= d && d <= 1_000_000_000L);
assert (1 <= w && w <= 1_000_000_000L);
assert (Math.max(vl, vr) < w);
BigDecimal s = checkai();
double u = souteikai();
assert (Math.abs(BigDecimal.valueOf(u).subtract(s).doubleValue()) < 1e-6);
System.out.println(gokai());
if (max(vl, vr, d, w) <= 1_000_000L) {
double g = gokai();
assert (Math.abs(BigDecimal.valueOf(g).subtract(s).doubleValue()) < 1e-6);
}
System.out.println(String.format("%.7f", u));
}
Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
new Main().run();
}
long max(long... a) {
long r = Long.MIN_VALUE;
for (long v : a) {
r = Math.max(r, v);
}
return r;
}
}