結果

問題 No.425 ジャンケンの必勝法
ユーザー d2verbd2verb
提出日時 2016-09-28 14:29:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 1,462 ms
コンパイル使用メモリ 145,144 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-13 12:55:28
合計ジャッジ時間 3,127 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
4,376 KB
testcase_01 AC 15 ms
4,380 KB
testcase_02 AC 16 ms
4,376 KB
testcase_03 AC 15 ms
4,376 KB
testcase_04 AC 15 ms
4,376 KB
testcase_05 AC 15 ms
4,380 KB
testcase_06 AC 16 ms
4,380 KB
testcase_07 AC 16 ms
4,376 KB
testcase_08 AC 16 ms
4,380 KB
testcase_09 AC 16 ms
4,376 KB
testcase_10 AC 16 ms
4,384 KB
testcase_11 AC 15 ms
4,380 KB
testcase_12 AC 15 ms
4,380 KB
testcase_13 AC 15 ms
4,376 KB
testcase_14 AC 16 ms
4,380 KB
testcase_15 AC 16 ms
4,376 KB
testcase_16 AC 16 ms
4,376 KB
testcase_17 AC 15 ms
4,380 KB
testcase_18 AC 15 ms
4,380 KB
testcase_19 AC 16 ms
4,380 KB
testcase_20 AC 16 ms
4,380 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 15 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<29)
#define INFLL (1L<<29)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int Cost;
struct Edge {
  int src, dst; Cost cost;
  Edge(int s, int d, Cost c) : src(s), dst(d), cost(c) {}
};
typedef vector<Edge>  Edges;
typedef vector<Edges> Graph;
typedef vector<Cost>  Array;
typedef vector<Array> Matrix;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

double p, q;

double solve(double p, int depth) {
  if (depth > 20) return 1;

  double _p = 0;
  _p += p / 2;
  _p += p / 2 * solve(max(0.0, p - q), depth + 1);
  _p += (1.0 - p) / 3;
  _p += (1.0 - p) / 3 * solve(min(1.0, p + q), depth + 1);

  return _p;
}

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cin >> p >> q;
  p /= 100.0; q /= 100.0;
  cout << fixed << setprecision(10) << (1.0 + solve(p, 0)) / 3.0 << endl;
  return 0; 
}
0