結果

問題 No.813 ユキちゃんの冒険
ユーザー hanbei_dayohanbei_dayo
提出日時 2019-12-15 00:00:13
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 3,375 ms
コンパイル使用メモリ 70,764 KB
実行使用メモリ 11,564 KB
最終ジャッジ日時 2023-08-30 15:34:18
合計ジャッジ時間 5,246 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 WA -
testcase_02 AC 25 ms
6,216 KB
testcase_03 WA -
testcase_04 AC 64 ms
11,516 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 47 ms
7,312 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 60 ms
10,648 KB
testcase_17 WA -
testcase_18 AC 7 ms
4,384 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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