結果

問題 No.425 ジャンケンの必勝法
ユーザー motimoti
提出日時 2016-09-23 00:45:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,097 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 1,747 ms
コンパイル使用メモリ 171,448 KB
実行使用メモリ 67,432 KB
最終ジャッジ日時 2023-08-11 06:01:15
合計ジャッジ時間 9,740 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
5,148 KB
testcase_01 AC 7 ms
5,044 KB
testcase_02 AC 13 ms
5,656 KB
testcase_03 AC 25 ms
7,064 KB
testcase_04 AC 128 ms
16,572 KB
testcase_05 AC 30 ms
7,636 KB
testcase_06 AC 76 ms
11,900 KB
testcase_07 AC 110 ms
14,388 KB
testcase_08 AC 27 ms
6,888 KB
testcase_09 AC 24 ms
6,900 KB
testcase_10 AC 12 ms
5,616 KB
testcase_11 AC 1,092 ms
67,336 KB
testcase_12 AC 1,028 ms
67,244 KB
testcase_13 AC 1,082 ms
67,212 KB
testcase_14 AC 1,027 ms
67,432 KB
testcase_15 AC 7 ms
5,084 KB
testcase_16 AC 7 ms
5,028 KB
testcase_17 AC 1,093 ms
67,224 KB
testcase_18 AC 24 ms
7,112 KB
testcase_19 AC 25 ms
6,956 KB
testcase_20 AC 1,097 ms
67,188 KB
testcase_21 AC 7 ms
5,196 KB
testcase_22 AC 7 ms
5,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;

int P0, Q;

map<pair<int, int>, double> memo;

double solve(int P, int depth = 0) {
  if(depth > 1e4) return 1.0f;
  if(memo.find({P, depth}) != memo.end()) return memo[{P, depth}];
  auto& ret = memo[{P, depth}];
  return ret =
  P / 200.0 + (100 - P) / 300.0
  + P / 200.0         * solve(max(0,    P-Q), depth + 1)
  + (100 - P) / 300.0 * solve(min(100,  P+Q), depth + 1);
}

int main() {

  cin >> P0 >> Q;
  printf("%.10f\n", (1 + solve(P0)) / 3);

  return 0;
}
0