Tribles UVA – 11021

Miku


首先我们要知道,如果一个毛虫死亡的概率是P,那么两个毛球死亡概率就是$p^2$

然后对于定义dp[i]表示一只毛球死在i天的可能性,就可以得到递推式

$dp_i=p_0+p1*dp{i-1}+p2*(dp{i-1})^2+····p_{n-1}*(dp_i-1)^{n-1}$
其中为什那么会有一堆指数呢?原因如上

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int t;
int n,k,m;
double p[1001];
int x;
double dp[1001];
int main(){
    scanf("%d",&t);
    x=t;
    while(t--){
    //  cout<<t<<endl;
        scanf("%d%d%d",&n,&k,&m);
        for(int i=0;i<n;++i)
            scanf("%lf",&p[i]);
        dp[0]=0;
    //  cout<<"LL";
        dp[1]=p[0];
        for(int i=2;i<=m;++i){
            dp[i]=0;
            for(int j=0;j<n;++j){
                dp[i]+=p[j]*pow(dp[i-1],j);
            }
        }
        printf("Case #%d: %.7lfn",x-t,pow(dp[m],k));
    }
    return 0;
} 
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇