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

1001 为什么我总是wrong answer请大虾指点

Posted by fujin at 2008-04-05 10:01:42 on Problem 1001
以下是我的代码:
#include<stdio.h>
#include<math.h>
#include<string.h>
# define d 5
void main()
{int h,i,j,k,m,n,r,s,t,u,v=0,w,x,y,z=0,a[151]={0},b[d],c[151];
	 for(w=d-1;w>=0;w--)
	{
		y=getchar();
		if(y!='.')
		  c[w]=b[w]=y-48;
		else
	   {
		 w++;
		 v=w;
	   }
   }
	 scanf("%d",&h);
	 if((n=h)==1)
	 {   memset(c,0,131);
		 c[0]=1;
		 c[1]=0;
		 c[2]=0;
		 c[3]=0;
		 c[4]=0;
	 }
	 else
	   n=h-1;
	 for(i=1,s=d;i<=n;i++)
	{
	  memset(a,0,131);
	  for(j=0;j<d;j++)
	  for(k=0,m=0;k<s;k++,m++)
      {
		 a[m+j]+=(b[j]*c[k])%10;
         if(a[m+j]>=10)
         {   
			a[m+j+1]+=a[m+j]/10;
			a[m+j]=a[m+j]%10;
		 }
		 a[m+j+1]+=(b[j]*c[k])/10;
		 if(a[m+j+1]>=10)
		 {
			a[m+j+2]+=a[m+j+1]/10;
			a[m+j+1]=a[m+j+1]%10;
		 }
	  }
	  for(r=0;r<m+j;r++)
		 c[r]=a[r];
	  s=m+j;
	}
	u=s-1;
	while(a[u]==0&&u>v*h-1)
	   u--;
	while(a[z]==0)
	   z++;
	for(t=u;t>=z;t--)
   {
	  if(h==1&&t==v-1)
		printf(".");
	  else
		if(t==v*h-1)
		  printf(".");
	  printf("%d",a[t]);
   }
	printf("\n");
}
我试过了 只有0。4321 20 这组数据有问题。。。。

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