結果

問題 No.813 ユキちゃんの冒険
ユーザー 沙耶花沙耶花
提出日時 2020-12-08 15:27:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 2,148 ms
コンパイル使用メモリ 206,752 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 17:17:17
合計ジャッジ時間 15,391 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 362 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 1,087 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 393 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 514 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 969 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 59 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 5 ms
4,348 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000


int main(){
	
	int N;
	cin>>N;
	double p,q;
	cin>>p>>q;
	
	vector dp(N,vector<double>(2,0.0));
	dp[0][0] = 1.0;
	
	double ans = 0.0;
	
	rep(_,20000){
		vector ndp(N,vector<double>(2,0.0));
		
		rep(i,N){
			if(i!=0){
				ndp[i-1][1] += dp[i][0]*p;
				ndp[i-1][1] += dp[i][1]*q;
			}
			else{
				ans += dp[i][0]*p;
				ans += dp[i][1]*q;
			}
			if(i!=N-1){
				ndp[i+1][0] += dp[i][0]*q;
				ndp[i+1][1] += dp[i][1]*p;
			}
		}
		
		swap(dp,ndp);
		
	}
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	return 0;
}
0