"ZOJ" "3329" one person Game

Source: Internet
Author: User

Probability DP

Kuangbin summed up the third way in the title

It seems that there is no state of entry ah ... It's all about DP. Of course, to find "the transition between states" ...

In the subject Dp[i] and dp[i-(K1+K2+K3)] to Dp[i-1] all have relations ... Then all the dp[i] are related to dp[0] that is ans ...

Use "factor" to transfer ... sigh has been getting more and more water lately.

1 //Bzoj2#include <cmath>3#include <vector>4#include <cstdio>5#include <cstring>6#include <cstdlib>7#include <iostream>8#include <algorithm>9 #defineRep (i,n) for (int i=0;i<n;++i)Ten #defineF (i,j,n) for (int i=j;i<=n;++i) One #defineD (i,j,n) for (int i=j;i>=n;--i) A #definePB Push_back - using namespacestd; - intGetint () { the     intv=0, sign=1;CharCh=GetChar (); -      while(!isdigit (CH)) {if(ch=='-') sign=-1; Ch=GetChar ();} -      while(IsDigit (CH)) {v=v*Ten+ch-'0'; Ch=GetChar ();} -     returnv*Sign ; + } - Const intn=1e7+Ten, inf=~0u>>2; + /*******************template********************/ A  at Doublea[505],b[505],p[ -]; -  - intMain () { - //freopen ("Input.txt", "R", stdin); -     intt=getint (); -     intK1,k2,k3,a,b,c,n; in      while(t--){ -N=getint (); K1=getint (); K2=getint (); k3=getint (); toA=getint (); B=getint (); C=getint (); +         Doublep0=1.0/k1/k2/K3; -Memset (P,0,sizeofp); theF (I,1, K1) F (J,1, K2) F (k,1, K3) *             if(I!=a | | j!=b | | k!=c) p[i+j+k]+=P0; $             Panax NotoginsengD (I,n,0){ -A[i]=p0; b[i]=1; theF (J,1, k1+k2+K3) { +                 if(i+j>n) Break; Aa[i]+=a[i+j]*P[j]; theb[i]+=b[i+j]*P[j]; +             } -         } $printf"%.15lf\n", b[0]/(1-a[0])); $     } -     return 0; -}
View Code

"ZOJ" "3329" one person Game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.