結果

問題 No.425 ジャンケンの必勝法
ユーザー akakimidoriakakimidori
提出日時 2017-04-24 15:31:38
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 25,140 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-11 13:06:57
合計ジャッジ時間 2,517 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>

double calc(int depth,int p,int q){
  if(depth>=20){
    return 0.5;
  }
  if(p<=0){
    return 1.0/3.0+calc(depth+1,q,q)/3.0;
  } else if(p>=100){
    return 1.0/2.0+calc(depth+1,100-q,q)/2.0;
  }
  return (1.0/2.0+calc(depth+1,p-q,q)/2.0)*p/100.0
    +(1.0/3.0+calc(depth+1,p+q,q)/3.0)*(100-p)/100.0;
}

void run(void){
  int p,q;
  scanf("%d%d",&p,&q);

  double ans=1.0/3.0+calc(0,p,q)/3.0;
  printf("%.6lf\n",ans);
  return;
}

int main(void){
  run();
  return 0;
}
0