Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

我的程序为什么是错的呀?哪位牛人帮忙看下!!

Posted by scuxy at 2008-03-12 14:46:50 on Problem 3519
#include<stdio.h>
#include<memory.h>
double p[102][102];
int l[102],b[102];
int main()
{
	int n,t,ll,bb;
	while(scanf("%d%d%d%d",&n,&t,&ll,&bb)==4)
	{
       int i,j,k;
	   memset(p,0,sizeof(p));
	   memset(l,0,sizeof(l));
	   memset(b,0,sizeof(b));
	   for(i=0;i<ll;i++)
	   { 
		   scanf("%d",&k);
            l[k]=1;
	   }
	   for(j=0;j<bb;j++)
	   {   
		   scanf("%d",&k);
		   b[k]=1;
	   }
	   p[0][0]=1.0;
	     double re=0.0;
	   for(i=1;i<=t;i++)
	   {
		   for(j=1;j<=n;j++)
		   {
			   int w;
			      w=j;
			   if(b[j]==1)
                   w=0;
			  for(k=j-1;k>=j-6&&k>=0;k--)
			  {

				  p[i][w]=p[i][w]+p[i-1][k]/6.0;
			  }
			  if(j!=n)
			  {
			   for(k=2*n-6-j;k<=n&&n-k<6;k++)
				  p[i][w]=p[i][w]+p[i-1][k]/6.0;
			  }
			  if(l[j]==1)
			  {
				  p[i+1][w]=p[i+1][w]+p[i][w]/6.0;//
			  }
		   }
		  re=re+p[i][n];
	   }
    printf("%.6lf\n",re);
	}
	return 0;
}




Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator