結果
問題 | No.425 ジャンケンの必勝法 |
ユーザー |
|
提出日時 | 2016-09-22 23:41:23 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 957 bytes |
コンパイル時間 | 3,440 ms |
コンパイル使用メモリ | 77,836 KB |
実行使用メモリ | 41,644 KB |
最終ジャッジ日時 | 2024-11-17 19:41:43 |
合計ジャッジ時間 | 7,044 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 18 |
ソースコード
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);}}}