結果
| 問題 |
No.76 回数の期待値で練習
|
| コンテスト | |
| ユーザー |
konaaiocxvmq982
|
| 提出日時 | 2020-03-27 23:59:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 5,000 ms |
| コード長 | 3,099 bytes |
| コンパイル時間 | 1,473 ms |
| コンパイル使用メモリ | 163,704 KB |
| 実行使用メモリ | 11,516 KB |
| 最終ジャッジ日時 | 2025-01-02 10:00:56 |
| 合計ジャッジ時間 | 1,909 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
namespace Kunitaka{
template<
typename TYPE,
std::size_t SIZE
>
std::size_t array_length(const TYPE (&array)[SIZE])
{
return SIZE;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
}
using namespace Kunitaka;
namespace Printer{
void br(){
cout << endl;
}
void loop_cnt(int i){
cout << "i = " << i << endl;
}
void loop_cnt(int i, int j){
cout << "i = " << i << ", " << "j = " << j << endl;
}
template<class T>
void print(T x){
cout << x << endl;
}
template<class T, class S>
void print(T x, S y){
cout << x << "," << y << endl;
}
template<class T, class S, class U>
void print(T x, S y, U z){
cout << x << "," << y << "," << z << endl;
}
template<class T, class S>
void print(pair<T, S> p){
cout << p.first << ", " << p.second << endl;
}
template<
typename TYPE,
std::size_t SIZE
>
void print(const TYPE (&array)[SIZE]){
int lim = array_length(array);
for(int i=0; i<lim; i++){
if(i) cout << " ";
cout << array[i];
}
cout << endl;
}
template<class S>
void print(vector<S> v){
for(int i=0; i<v.size(); i++){
if(i) cout << " ";
cout<< v[i];
}
cout << endl;
}
template<class S>
void print(vector<vector<S> > vv){
for(int i=0; i<vv.size(); i++){
for(int j=0; j<vv[i].size(); j++){
if(j) cout << " ";
cout << vv[i][j];
}
cout << endl;
}
}
void yesno(bool x){
if(x) cout << "Yes" << endl;
else cout << "No" << endl;
}
};
using namespace Printer;
int T;
double DP[1000057];
double S[7];
void solve() {
int i,j,k,l,r,x,y; string s;
DP[1+10] = 1.0833333333333333;
DP[2+10] = 1.2569444444444444;
DP[3+10] = 1.5353009259259260;
DP[4+10] = 1.6915991512345676;
DP[5+10] = 2.0513639724794235;
DP[6+10] = 5.7894594000345325;
S[1]=1.0/12;
S[2]=2.0/12;
S[3]=3.0/12;
S[4]=1.0/12;
S[5]=3.0/12;
S[6]=2.0/12;
for(i=1;i<=1000006;i++) {
DP[i+10]=1+(DP[i+10-1]*S[1]+DP[i+10-2]*S[2]+DP[i+10-3]*S[3]+DP[i+10-4]*S[4]+DP[i+10-5]*S[5]+DP[i+10-6]*S[6]);
}
cin>>T;
rep(i,T) {
cin>>x;
printf("%.12lf\n",DP[x+10]);
}
}
int main(int argc, const char * argv[]) {
//提出時、消す----//
//--------------//
// input
cout << fixed << setprecision(10);
solve();
return 0;
}
konaaiocxvmq982