結果

問題 No.425 ジャンケンの必勝法
ユーザー kuuso1kuuso1
提出日時 2016-09-23 00:13:06
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 1,846 bytes
コンパイル時間 7,518 ms
コンパイル使用メモリ 107,488 KB
実行使用メモリ 30,936 KB
最終ジャッジ日時 2023-08-11 05:58:32
合計ジャッジ時間 8,640 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 210 ms
28,744 KB
testcase_01 AC 210 ms
28,744 KB
testcase_02 AC 213 ms
29,040 KB
testcase_03 AC 211 ms
28,900 KB
testcase_04 AC 208 ms
28,940 KB
testcase_05 AC 205 ms
26,844 KB
testcase_06 AC 202 ms
28,956 KB
testcase_07 AC 205 ms
26,984 KB
testcase_08 AC 204 ms
28,768 KB
testcase_09 AC 204 ms
28,916 KB
testcase_10 AC 205 ms
28,752 KB
testcase_11 AC 204 ms
24,784 KB
testcase_12 AC 205 ms
26,796 KB
testcase_13 AC 206 ms
26,748 KB
testcase_14 AC 209 ms
28,860 KB
testcase_15 AC 206 ms
24,852 KB
testcase_16 AC 208 ms
26,852 KB
testcase_17 AC 213 ms
28,820 KB
testcase_18 AC 205 ms
30,936 KB
testcase_19 AC 209 ms
28,812 KB
testcase_20 AC 211 ms
28,896 KB
testcase_21 AC 204 ms
24,776 KB
testcase_22 AC 204 ms
26,976 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;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		double win = 1.0/3.0;
		double[][] dp = new double[2][];
		for(int i=0;i<2;i++)dp[i] = new double[101];
		dp[0][P0] = 1.0/3.0;
		double eps = 1e-9;
		
		for(int t=0;t<(int)5e4;t++){
			
			double[][] nxt = new double[2][];
			for(int i=0;i<2;i++)nxt[i] = new double[101];
			
			for(int i=0;i<101;i++){
				//if(dp[0][i] < eps)continue;
				win += dp[0][i] * 0.5 * (i/100.0);
				nxt[1][Math.Max(0,i-Q)] += dp[0][i] * 0.5 *(i/100.0);
				
				win += dp[0][i] * (1.0/3.0) * (1.0 - (i/100.0) );
				nxt[0][Math.Min(100,i+Q)] += dp[0][i] * (1.0/3.0) *(1.0-(i/100.0));
			}
			for(int i=0;i<101;i++){
				//if(dp[1][i] < eps)continue;
				win += dp[1][i] * 0.5 * (i/100.0);
				nxt[1][Math.Max(0,i-Q)] += dp[1][i] * 0.5 *(i/100.0);
				
				win += dp[1][i] * (1.0/3.0) * (1.0 - (i/100.0) );
				nxt[0][Math.Min(100,i+Q)] += dp[1][i] * (1.0/3.0) *(1.0-(i/100.0));
			}
			
			dp = nxt;
		}
		
		Console.WriteLine(win);
		
	}
	int P0,Q;
	public Sol(){
		var d = ria();
		P0 = d[0];
		Q = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
0