結果

問題 No.76 回数の期待値で練習
ユーザー 👑 kmjpkmjp
提出日時 2014-11-24 00:15:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 1,052 bytes
コンパイル時間 2,089 ms
コンパイル使用メモリ 144,732 KB
実行使用メモリ 11,524 KB
最終ジャッジ日時 2023-08-30 22:37:02
合計ジャッジ時間 1,616 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
11,524 KB
testcase_01 AC 17 ms
11,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int T;
double DP[1000057];

int A[7];
double S[7];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	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;
	FOR(i,T) {
		cin>>x;
		_P("%.12lf\n",DP[x+10]);
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0