結果

問題 No.425 ジャンケンの必勝法
ユーザー tomeruntomerun
提出日時 2016-09-22 22:48:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 347 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 75,304 KB
実行使用メモリ 56,284 KB
最終ジャッジ日時 2023-08-11 05:36:51
合計ジャッジ時間 11,132 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 338 ms
56,204 KB
testcase_01 AC 330 ms
55,880 KB
testcase_02 AC 328 ms
55,792 KB
testcase_03 AC 336 ms
56,140 KB
testcase_04 AC 329 ms
55,924 KB
testcase_05 AC 335 ms
55,984 KB
testcase_06 AC 339 ms
56,032 KB
testcase_07 AC 338 ms
56,100 KB
testcase_08 AC 347 ms
55,784 KB
testcase_09 AC 338 ms
55,960 KB
testcase_10 AC 339 ms
56,032 KB
testcase_11 AC 345 ms
56,108 KB
testcase_12 AC 332 ms
55,680 KB
testcase_13 AC 333 ms
55,624 KB
testcase_14 AC 340 ms
56,176 KB
testcase_15 AC 331 ms
55,764 KB
testcase_16 AC 343 ms
56,284 KB
testcase_17 AC 330 ms
55,884 KB
testcase_18 AC 337 ms
56,116 KB
testcase_19 AC 336 ms
55,844 KB
testcase_20 AC 325 ms
56,048 KB
testcase_21 AC 331 ms
55,896 KB
testcase_22 AC 332 ms
56,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int P = sc.nextInt();
		int Q = sc.nextInt();
		double[][] dp = new double[2][101];
		double ans = 1.0 / 3;
		dp[0][P] = 1.0 / 3;
		int t = 0;
		for (int i = 0; i < 100000; ++i) {
			Arrays.fill(dp[1 - t], 0);
			for (int j = 0; j <= 100; ++j) {
				// use
				ans += 0.01 * j * dp[t][j] / 2;
				dp[1 - t][Math.max(0, j - Q)] += 0.01 * j * dp[t][j] / 2;

				// not use
				ans += 0.01 * (100 - j) * dp[t][j] / 3;
				dp[1 - t][Math.min(100, j + Q)] += 0.01 * (100 - j) * dp[t][j] / 3;
			}
			t = 1 - t;
		}
		System.out.printf("%.9f\n", ans);
	}
}
0