結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2016-09-23 00:13:06 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 172 ms / 2,000 ms |
| コード長 | 1,846 bytes |
| コンパイル時間 | 1,342 ms |
| コンパイル使用メモリ | 108,032 KB |
| 実行使用メモリ | 22,784 KB |
| 最終ジャッジ日時 | 2024-11-17 19:44:38 |
| 合計ジャッジ時間 | 6,031 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
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));}
}
kuuso1