結果

問題 No.425 ジャンケンの必勝法
ユーザー claw88claw88
提出日時 2016-09-22 23:50:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,463 bytes
コンパイル時間 3,766 ms
コンパイル使用メモリ 102,172 KB
実行使用メモリ 26,728 KB
最終ジャッジ日時 2023-08-11 05:56:05
合計ジャッジ時間 7,491 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
24,756 KB
testcase_01 AC 104 ms
22,852 KB
testcase_02 AC 103 ms
22,820 KB
testcase_03 AC 104 ms
24,760 KB
testcase_04 AC 109 ms
26,728 KB
testcase_05 AC 103 ms
22,724 KB
testcase_06 AC 106 ms
20,684 KB
testcase_07 AC 106 ms
22,676 KB
testcase_08 AC 107 ms
22,924 KB
testcase_09 AC 104 ms
22,892 KB
testcase_10 AC 103 ms
22,752 KB
testcase_11 AC 105 ms
22,848 KB
testcase_12 AC 108 ms
24,812 KB
testcase_13 AC 105 ms
22,824 KB
testcase_14 AC 105 ms
24,732 KB
testcase_15 AC 106 ms
24,780 KB
testcase_16 AC 109 ms
22,692 KB
testcase_17 AC 107 ms
22,784 KB
testcase_18 AC 106 ms
22,872 KB
testcase_19 AC 103 ms
22,760 KB
testcase_20 AC 107 ms
22,812 KB
testcase_21 AC 108 ms
20,880 KB
testcase_22 AC 106 ms
24,748 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yuki_425
{
    class Program
    {
        static double p0, q;
        const int MAX = 20;
        static double ans = (double)1 / 3;
        static void Main(string[] args)
        {
            var t = scan;
            p0 = (double)t[0] / 100; q = (double)t[1] / 100;
            double st = (double)1 / 3;

            //はじめに必勝法

            double memo = st * p0;
            use(memo, 0,p0);

            //はじめに使わない

            memo = st * (1- p0);
            nouse(memo, 0,p0);


            Console.WriteLine(ans.ToString("F7"));
        }
        static void use(double per, int cnt,double pp)
        {
            if (cnt > MAX) return;
            ans += per / 2;
            //Console.WriteLine(per+" "+ans);
            double p = Math.Max(0, pp - q);
            use(p  * per / 2, cnt + 1, p);
            nouse((1- p) * per / 2, cnt + 1, p);
        }
        static void nouse(double per, int cnt, double pp)
        {
            if (cnt > MAX) return;
            ans += per / 3;
            //Console.WriteLine(per +" " +ans);
            double p = Math.Min(1, pp + q);
            use(p * per / 3, cnt + 1, p);
            nouse((1 - p) * per / 3, cnt + 1, p);
        }
        static int[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), int.Parse); } }
    }
}
0