标签:des style blog io color ar os java sp
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 929 Accepted Submission(s):
265
Special Judge
1 /* dp[i+1][j] 2 dp[i][j]= 3 dp[i+1][num[i]] 4 */ 5 #include<iostream> 6 #include<cstdio> 7 #include<cstring> 8 #include<algorithm> 9 #include<string> 10 #include<set> 11 #include<map> 12 #include<vector> 13 #include<stack> 14 #include<queue> 15 using namespace std; 16 const int ms=12; 17 const int cms=122; 18 const int MAXN=10002; 19 double dp[MAXN][cms]; 20 double p[cms][cms]; 21 int num[MAXN]; 22 int main() 23 { 24 int i,j,k,t,n,m,cnt; 25 while(scanf("%d",&n)!=EOF) 26 { 27 for(cnt=1,i=n;i>=(n-3+1);i--) 28 cnt*=i; 29 cnt/=6; 30 for(i=0;i<cnt;i++) 31 for(j=0;j<cnt;j++) 32 scanf("%lf",&p[i][j]); 33 scanf("%d",&m); 34 for(i=1;i<=m;i++) 35 scanf("%d",&num[i]); 36 for(i=0;i<=cnt;i++) 37 dp[m+1][i]=1.0; 38 for(i=m;i>0;i--) 39 { 40 for(j=0;j<cnt;j++) 41 { 42 dp[i][j]=p[j][num[i]]*max(dp[i+1][j],dp[i+1][num[i]]); 43 } 44 } 45 double ans=-1.0; 46 for(j=0;j<cnt;j++) 47 if(ans<dp[1][j]) 48 ans=dp[1][j]; 49 printf("%.6lf\n",ans); 50 } 51 return 0; 52 }
标签:des style blog io color ar os java sp
原文地址:http://www.cnblogs.com/767355675hutaishi/p/4089941.html