結果
| 問題 |
No.75 回数の期待値の問題
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2014-11-23 23:53:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 396 bytes |
| コンパイル時間 | 301 ms |
| コンパイル使用メモリ | 27,392 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 20:43:43 |
| 合計ジャッジ時間 | 1,127 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d", &K);
| ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio>
int K;
double F[201], G[201];
int main(){
scanf("%d", &K);
F[K] = 0.0f; G[K] = 0.0f;
for(int i=K-1;i>=0;i--){
for(int j=1;j<=6;j++){
if(i+j <= K){F[i] += 1.0f/6.0f * F[i+j]; G[i] += 1.0f/6.0f * G[i+j];}
else{F[i] += 1.0f/6.0f;}
}
G[i] += 1.0f;
}
printf("%.30f\n", G[0] / (1.0f-F[0]));
}
tottoripaper