結果

問題 No.425 ジャンケンの必勝法
ユーザー ぴろずぴろず
提出日時 2016-09-22 22:52:32
言語 Java19
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 3,309 ms
コンパイル使用メモリ 73,952 KB
実行使用メモリ 56,376 KB
最終ジャッジ日時 2023-08-11 05:44:51
合計ジャッジ時間 7,699 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
55,676 KB
testcase_01 AC 128 ms
56,376 KB
testcase_02 AC 129 ms
56,072 KB
testcase_03 AC 132 ms
55,668 KB
testcase_04 AC 130 ms
55,972 KB
testcase_05 AC 130 ms
56,212 KB
testcase_06 AC 131 ms
55,500 KB
testcase_07 AC 132 ms
55,684 KB
testcase_08 AC 128 ms
55,772 KB
testcase_09 AC 126 ms
56,288 KB
testcase_10 AC 128 ms
55,620 KB
testcase_11 AC 130 ms
55,720 KB
testcase_12 AC 132 ms
53,952 KB
testcase_13 AC 132 ms
56,052 KB
testcase_14 AC 131 ms
55,828 KB
testcase_15 AC 125 ms
56,048 KB
testcase_16 AC 122 ms
55,680 KB
testcase_17 AC 132 ms
56,092 KB
testcase_18 AC 135 ms
55,972 KB
testcase_19 AC 129 ms
55,852 KB
testcase_20 AC 132 ms
55,796 KB
testcase_21 AC 129 ms
56,096 KB
testcase_22 AC 129 ms
56,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no425;

import java.util.Scanner;

public class Main {

	static int N = 1000;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int p0 = sc.nextInt();
		int q = sc.nextInt();
		double[][] dp = new double[N+1][101];
		dp[1][p0] = 1D / 3;
		double ans = 1D / 3;
		for(int i=1;i<N;i++) {
			for(int j=0;j<=100;j++) {
				if (dp[i][j] == 0) continue;
//				System.out.println(i + "," + j + ":" + dp[i][j]);
				//使う
				ans += dp[i][j] * j / 100 / 2;
				dp[i+1][Math.max(j - q, 0)] += dp[i][j] * j / 100 / 2;
				//使わない
				ans += dp[i][j] * (100 - j) / 100 / 3;
				dp[i+1][Math.min(j + q, 100)] += dp[i][j] * (100 - j) / 100 / 3;
			}
		}
		System.out.println(String.format("%.7f", ans));
	}

}
0