結果

問題 No.450 ベー君のシャトルラン
ユーザー uafr_csuafr_cs
提出日時 2017-11-04 19:38:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 1,167 bytes
コンパイル時間 3,970 ms
コンパイル使用メモリ 83,656 KB
実行使用メモリ 41,988 KB
最終ジャッジ日時 2024-05-03 04:04:57
合計ジャッジ時間 6,744 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
41,168 KB
testcase_01 AC 144 ms
41,416 KB
testcase_02 AC 147 ms
41,652 KB
testcase_03 AC 149 ms
41,388 KB
testcase_04 AC 146 ms
41,592 KB
testcase_05 AC 145 ms
41,564 KB
testcase_06 AC 145 ms
41,772 KB
testcase_07 AC 132 ms
40,924 KB
testcase_08 AC 144 ms
41,888 KB
testcase_09 AC 145 ms
41,600 KB
testcase_10 AC 135 ms
40,924 KB
testcase_11 AC 147 ms
41,688 KB
testcase_12 AC 143 ms
41,676 KB
testcase_13 AC 130 ms
40,976 KB
testcase_14 AC 147 ms
41,364 KB
testcase_15 AC 145 ms
41,368 KB
testcase_16 AC 132 ms
40,952 KB
testcase_17 AC 143 ms
41,400 KB
testcase_18 AC 148 ms
41,420 KB
testcase_19 AC 194 ms
41,648 KB
testcase_20 AC 144 ms
41,496 KB
testcase_21 AC 148 ms
41,464 KB
testcase_22 AC 146 ms
41,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static double[] run(double d, double w, double vl, double vr){
		double running = 0;
		
		final double go_right_t = d / (w + vr);
		running += w * go_right_t;
		d -= go_right_t * (vl + vr);
		
		final double go_left_t = d / (w + vl);
		running += w * go_left_t;
		d -= go_left_t * (vl + vr);
		
		return new double[]{d, running};
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final double vl = sc.nextDouble();
		final double vr = sc.nextDouble();
		
		final double d = sc.nextDouble();
		final double w = sc.nextDouble();
		
		double[] first_try = run(d, w, vl, vr);
		final double second_d = first_try[0];
		
		double[] second_try = run(second_d, w, vl, vr);
		
		final double first_run  = first_try[1];
		final double second_run = second_try[1];
		
		final double rate = second_run / first_run;
		final double limit = first_run / (1 - rate);
		//System.out.println(first_run + " " + second_run + " " + rate + " " + limit);
		
		System.out.printf("%.8f\n", limit);
	}
}
0