結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-22 23:50:50 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 74 ms / 2,000 ms |
| コード長 | 1,463 bytes |
| コンパイル時間 | 1,148 ms |
| コンパイル使用メモリ | 114,108 KB |
| 実行使用メモリ | 27,208 KB |
| 最終ジャッジ日時 | 2024-11-17 19:42:47 |
| 合計ジャッジ時間 | 3,211 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 18 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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); } }
}
}