結果

問題 No.425 ジャンケンの必勝法
ユーザー hermione17hermione17
提出日時 2016-09-22 22:57:54
言語 Java19
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 722 bytes
コンパイル時間 4,785 ms
コンパイル使用メモリ 72,192 KB
実行使用メモリ 56,616 KB
最終ジャッジ日時 2023-08-11 05:45:37
合計ジャッジ時間 7,657 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,632 KB
testcase_01 AC 126 ms
55,824 KB
testcase_02 AC 124 ms
56,616 KB
testcase_03 AC 123 ms
55,836 KB
testcase_04 AC 124 ms
55,760 KB
testcase_05 AC 124 ms
55,880 KB
testcase_06 AC 127 ms
55,556 KB
testcase_07 AC 123 ms
55,596 KB
testcase_08 AC 128 ms
55,700 KB
testcase_09 AC 128 ms
55,632 KB
testcase_10 AC 132 ms
55,424 KB
testcase_11 AC 126 ms
55,888 KB
testcase_12 AC 127 ms
55,688 KB
testcase_13 AC 127 ms
55,828 KB
testcase_14 AC 125 ms
55,752 KB
testcase_15 AC 125 ms
55,924 KB
testcase_16 AC 124 ms
55,644 KB
testcase_17 AC 124 ms
55,484 KB
testcase_18 AC 123 ms
55,524 KB
testcase_19 AC 123 ms
55,472 KB
testcase_20 AC 125 ms
55,608 KB
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintStream;
import java.util.Scanner;


public class Y425 {
	int p0;
	int q;
	
	Y425() throws Exception {
		Scanner in = new Scanner(System.in);
		PrintStream out = new PrintStream(System.out);
		
		p0 = in.nextInt();
		q = in.nextInt();
		
		double ans = 1.0 / 3;
		
		ans += dfs(p0, 1.0 / 3);
		
		out.println(ans);
		out.flush();
	}

	double dfs(int p, double s) {
		if (s < 1e-9) return s / 2.0;
		
		double ans = 0;
		ans += p / 100.0 * 0.5 * s;
		ans += dfs(Math.max(0, p - q), p / 100.0 * s * 0.5);
		ans += (100 - p) / 100.0 / 3.0 * s;
		ans += dfs(Math.min(100, p + q), (100 - p) / 100.0 * s / 3.0);
		return ans;
	}
	
	public static void main(String argv[]) throws Exception {
		new Y425();
	}
}
0