結果

問題 No.813 ユキちゃんの冒険
ユーザー Tomohiko HasegawaTomohiko Hasegawa
提出日時 2019-04-13 18:38:34
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,595 bytes
コンパイル時間 841 ms
コンパイル使用メモリ 65,532 KB
実行使用メモリ 26,992 KB
最終ジャッジ日時 2023-08-30 15:12:48
合計ジャッジ時間 3,756 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
22,664 KB
testcase_01 WA -
testcase_02 AC 64 ms
22,540 KB
testcase_03 AC 64 ms
22,588 KB
testcase_04 AC 59 ms
22,700 KB
testcase_05 AC 66 ms
24,684 KB
testcase_06 AC 65 ms
24,664 KB
testcase_07 AC 65 ms
22,608 KB
testcase_08 AC 64 ms
24,768 KB
testcase_09 WA -
testcase_10 AC 65 ms
22,588 KB
testcase_11 WA -
testcase_12 AC 64 ms
22,664 KB
testcase_13 AC 65 ms
24,580 KB
testcase_14 WA -
testcase_15 AC 65 ms
22,608 KB
testcase_16 AC 65 ms
24,784 KB
testcase_17 WA -
testcase_18 AC 65 ms
22,612 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 65 ms
24,752 KB
testcase_24 AC 64 ms
22,736 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.yukicoder
{
    class _813
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            double p = ReadDouble();
            double q = ReadDouble();
            if (p == 1)
            {
                WriteLine(1);
                return;
            }
            if (q == 1)
            {
                WriteLine(0);
                return;
            }

            double back = p;
            double go=q;
            for(int i = 1; i < n; i++)
            {
                back = back + p * go * go / (1 - back * p);
                go = go * q / (1 - back * p);
            }
            WriteLine(back);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}
0