結果
| 問題 |
No.425 ジャンケンの必勝法
|
| コンテスト | |
| ユーザー |
akakimidori
|
| 提出日時 | 2017-04-24 15:31:38 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 491 bytes |
| コンパイル時間 | 489 ms |
| コンパイル使用メモリ | 21,760 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 11:52:32 |
| 合計ジャッジ時間 | 1,328 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 18 |
コンパイルメッセージ
main.c: In function ‘run’:
main.c:18:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d%d",&p,&q);
| ^~~~~~~~~~~~~~~~~~~
ソースコード
#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;
}
akakimidori