結果
問題 | No.75 回数の期待値の問題 |
ユーザー |
![]() |
提出日時 | 2014-12-03 01:32:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,119 bytes |
コンパイル時間 | 549 ms |
コンパイル使用メモリ | 85,656 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 07:57:06 |
合計ジャッジ時間 | 1,228 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:39:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 39 | scanf("%d", &N); | ~~~~~^~~~~~~~~~
ソースコード
#include <iostream> #include <cmath> #include <cstdio> #include <algorithm> #include <string> #include <vector> #include <queue> #include <string.h> #include <map> #include <fstream> #include <functional> #include <bitset> #include <iomanip> #include <stack> #include <set> #include <climits> #define MAX_N 510 #define PI 3.141592653589 #define ESP 1e-10 #define BS 10 #define MOD 1000000007 #define ZERO 10001 #define YJSNPI 810 #define INF (1LL << 50) #define ADD(a, b) a = (a + (ll)b) % MOD #define MUL(a, b) a = (a * (ll)b) % MOD #define MAX(a, b) a = max(a, b) #define MIN(a, b) a = min(a, b) using namespace std; typedef long long ll; typedef pair<int, int> pi; int N; double dp[201][210]; int main() { scanf("%d", &N); double res = 0; dp[0][0] = 1; for(int i = 0; i < 200; i++) { for(int j = 0; j < N; j++) { if(dp[i][j] < ESP) continue; res += dp[i][j]; for(int k = 1; k <= 6; k++) { if(j + k <= N) { dp[i][j + k] += dp[i][j] / 6; } else { dp[i + 1][0] += dp[i][j] / 6; } } } } printf("%.9f\n", res); }