AE2A dynamic programming -


i have been trying solve problem: http://www.spoj.com/problems/ae2a/. know idea behind this, i'm getting wa. can me this? code is: https://ideone.com/rksw1p

for( int i=1; i<=n; i++) {     for( int j=1; j<=sum; j++)     {         for( int k=1; k<=6 && k<j; k++)         {             a[i][j] += a[i-1][j-k];         }     } } 

let numbers on top of die faces

x1,x2,x3... 

then have find ways in

x1+x2+x3+...+xn=sum 1<=xi<=6 

now, solution of integral equation (sum-1)c(n-1). hence probability ((sum-1)c(n-1))/(6^n). answer [((sum-1)c(n-1))/(6^n)x100] hope helps..


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -