結果
| 問題 | No.76 回数の期待値で練習 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-10-03 02:48:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 5,000 ms |
| コード長 | 1,253 bytes |
| コンパイル時間 | 1,479 ms |
| コンパイル使用メモリ | 84,884 KB |
| 実行使用メモリ | 11,316 KB |
| 最終ジャッジ日時 | 2024-07-19 19:11:07 |
| 合計ジャッジ時間 | 1,259 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
int inputValue(){
int a;
cin >> a;
return a;
};
template <typename T>
void output(T a, int precision) {
if(precision > 0){
cout << fixed << setprecision(precision) << a << "\n";
}
else{
cout << a << "\n";
}
}
int main() {
// source code
vector<double> E(1000000);
E[0] = 1.0000000000000000;
E[1] = 1.0833333333333333;
E[2] = 1.2569444444444444;
E[3] = 1.5353009259259260;
E[4] = 1.6915991512345676;
E[5] = 2.0513639724794235;
// 1:2:3:1:3:2
vector<double> P(6);
P[0] = 1.0 / 12;
P[1] = 2.0 / 12;
P[2] = 3.0 / 12;
P[3] = 1.0 / 12;
P[4] = 3.0 / 12;
P[5] = 2.0 / 12;
int T = inputValue();
repd(i, 6, E.size()){
E[i] = 0;
rep(j, 6){
E[i] += (1 + E[i - (j + 1)]) * P[j];
}
}
rep(i, T){
output(E[inputValue() - 1], 15);
}
return 0;
}