結果

問題 No.813 ユキちゃんの冒険
ユーザー hanbei_dayo
提出日時 2019-12-15 00:00:13
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 892 ms
コンパイル使用メモリ 76,120 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2025-01-02 07:12:21
合計ジャッジ時間 2,402 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
#include<stdio.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

double dp[1010][1010];

int main(void){
	ll n;
	double p,q;
	cin>>n>>p>>q;
	dp[0][0]=1.0;
	for(ll i=0;i<n;i++){
		for(ll x=0;x<=10000;x++){
			if(x%2==0){
				if(i+1!=n)dp[i+1][x+1]+=q*dp[i][x];
				if(i==0&&x==0)dp[i][x+1]+=p*dp[i][x];
				if(i!=0)dp[i][x+1]+=p*dp[i][x];
			}
			else{
				if(i-1>=0)dp[i-1][x+1]+=q*dp[i][x];
				if(i==0&&x==0)dp[i][x+1]+=p*dp[i][x];
				if(i!=0)dp[i][x+1]+=p*dp[i][x];
			}
		}
	}
	double sum=0.0;
	for(ll i=1;i<=1000;i++)if(i%2==1)sum+=dp[0][i];
	printf("%.16lf\n",sum);
    return 0;
}
0