結果

問題 No.425 ジャンケンの必勝法
ユーザー d2verbd2verb
提出日時 2016-09-28 14:25:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,208 bytes
コンパイル時間 1,573 ms
コンパイル使用メモリ 160,136 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 06:11:41
合計ジャッジ時間 2,739 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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(int p, int depth) {
  if (depth > 20) return 1;

  double tmp1;
  if (p - q < 0) tmp1 = solve(0, depth + 1);
  else tmp1 = solve(p - q, depth + 1);

  double tmp2;
  if (p + q > 1) tmp2 = solve(1, depth + 1);
  else tmp2 = solve(p + q, depth + 1);

  double _p = (p + 2 + 3 * p * tmp1 + 2 * tmp2 - 2 * p * tmp2) / 6.0;

  return _p;
}

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