結果

問題 No.425 ジャンケンの必勝法
ユーザー GrenacheGrenache
提出日時 2016-09-22 23:41:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 5,541 ms
コンパイル使用メモリ 74,764 KB
実行使用メモリ 57,408 KB
最終ジャッジ日時 2023-08-11 05:54:36
合計ジャッジ時間 7,187 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,516 KB
testcase_01 AC 122 ms
55,768 KB
testcase_02 AC 120 ms
55,464 KB
testcase_03 AC 122 ms
55,460 KB
testcase_04 AC 124 ms
55,756 KB
testcase_05 AC 121 ms
55,592 KB
testcase_06 AC 127 ms
55,336 KB
testcase_07 AC 127 ms
55,868 KB
testcase_08 AC 123 ms
55,484 KB
testcase_09 AC 122 ms
55,704 KB
testcase_10 AC 121 ms
55,460 KB
testcase_11 AC 118 ms
55,736 KB
testcase_12 AC 126 ms
56,228 KB
testcase_13 AC 125 ms
55,464 KB
testcase_14 AC 123 ms
53,536 KB
testcase_15 AC 121 ms
55,648 KB
testcase_16 AC 122 ms
57,408 KB
testcase_17 AC 122 ms
55,692 KB
testcase_18 AC 124 ms
55,740 KB
testcase_19 AC 124 ms
55,524 KB
testcase_20 AC 125 ms
55,636 KB
testcase_21 AC 126 ms
55,864 KB
testcase_22 AC 127 ms
55,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder425 {

	private static Scanner sc;
	private static Printer pr;

//	private static int p;
	private static int q;

	private static void solve() {
		int p = sc.nextInt();
		q = sc.nextInt();

		double ret = (double)1 / 3;

		pr.printf("%.7f\n", ret + f(p, (double)1 / 3));
	}

	private static double f(int p, double d) {
		double EPS = 1.e-10;
//		pr.println(d);
		if (d < EPS) {
			return 0;
		}
		double ret = d * p / 100 / 2 + d * (100 - p) / 100 / 3;
		ret += f(Math.max(0, p - q), d * p / 100 / 2);
		ret += f(Math.min(100, p + q), d * (100 - p) / 100 / 3);

		return ret;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0