結果

問題 No.162 8020運動
ユーザー ぴろずぴろず
提出日時 2015-03-06 00:37:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 278 ms / 5,000 ms
コード長 1,158 bytes
コンパイル時間 2,318 ms
コンパイル使用メモリ 74,384 KB
実行使用メモリ 56,796 KB
最終ジャッジ日時 2023-09-06 15:27:00
合計ジャッジ時間 10,588 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
55,780 KB
testcase_01 AC 225 ms
56,396 KB
testcase_02 AC 252 ms
56,304 KB
testcase_03 AC 273 ms
55,824 KB
testcase_04 AC 272 ms
56,180 KB
testcase_05 AC 276 ms
56,288 KB
testcase_06 AC 273 ms
55,836 KB
testcase_07 AC 274 ms
54,556 KB
testcase_08 AC 278 ms
56,232 KB
testcase_09 AC 155 ms
56,336 KB
testcase_10 AC 253 ms
56,080 KB
testcase_11 AC 224 ms
56,316 KB
testcase_12 AC 197 ms
56,524 KB
testcase_13 AC 270 ms
56,680 KB
testcase_14 AC 160 ms
56,272 KB
testcase_15 AC 160 ms
56,260 KB
testcase_16 AC 203 ms
56,412 KB
testcase_17 AC 197 ms
56,024 KB
testcase_18 AC 272 ms
56,560 KB
testcase_19 AC 250 ms
56,276 KB
testcase_20 AC 254 ms
56,056 KB
testcase_21 AC 254 ms
56,052 KB
testcase_22 AC 249 ms
56,120 KB
testcase_23 AC 252 ms
56,220 KB
testcase_24 AC 251 ms
55,996 KB
testcase_25 AC 263 ms
55,964 KB
testcase_26 AC 157 ms
56,216 KB
testcase_27 AC 231 ms
56,796 KB
testcase_28 AC 272 ms
56,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no162;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		double p0 = sc.nextInt() / 100.0;
		double p1 = sc.nextInt() / 100.0;
		double p2 = sc.nextInt() / 100.0;
		double[][] dp = new double[21][15];
		for(int i=0;i<15;i++) {
			dp[0][i] = i;
		}
		int n = 80 - a;
		for(int i=1;i<=n;i++) {
			for(int j=1;j<15;j++) {
				double e = 0;
				for(int k=0;k<1<<j;k++) { //抜け方
					double p = 1;
					for(int l=0;l<j;l++) {
						boolean nuketa = ((k>>l&1) == 1);
						int count = (l == 0 ? 0 : 1) + (l == j - 1 ? 0 : 1);
						if (count == 0) {
							p *= nuketa ? p0 : 1 - p0;
						}else if(count == 1) {
							p *= nuketa ? p1 : 1 - p1;
						}else{
							p *= nuketa ? p2 : 1 - p2;
						}
					}
					double sum = 0;
					int seq = 0;
					for(int l=0;l<=j;l++) {
						if ((k>>l&1) == 0 && (l < j)) {
							seq++;
						}else{
							sum += dp[i-1][seq];
							seq = 0;
						}
					}
					e += p * sum;
				}
				dp[i][j] = e;
			}
		}
//		System.out.println(Arrays.deepToString(dp));
		System.out.println(dp[n][14] * 2);
	}

}
0