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

Re:无语了,discuss里的所以BT数据都对了,就是WA ,代码贴出来,哪位大牛指点一下

Posted by dinner at 2008-11-06 10:20:51 on Problem 1001
In Reply To:无语了,discuss里的所以BT数据都对了,就是WA ,代码贴出来,哪位大牛指点一下 Posted by:sishen007 at 2008-10-31 14:03:06
> #include <iostream>
> #include <cstdio>
> #include <cstring>
> #define N 200
> using namespace std;
> int a[N],b[6],c[N];
> int main()
> {
> 	char r[7];
> 	int n;
> 	while(scanf("%s%d",r,&n)!=-1)
> 	{
> 		if(!n) {cout<<"1"<<endl;continue;}
> 		int i,j,k,t,fl=0,left=0,right=0,len;
> 		for(i=0;i<N;i++)
> 		{
> 			a[i]=0;
> 			c[i]=0;
> 		}
> 		for(i=0;i<6;i++)
> 		    b[i]=0;
> 		len=strlen(r);
> 		for(i=len-1,j=0;i>=0;i--)
> 		{
> 			if(r[i]=='.')
> 			{
> 			    fl=n*(len-1-i);
> 				continue;
> 			}
> 			b[j]=r[i]-'0';
> 			a[j]=b[j];
> 			j++;
> 		}
> 		for(t=0;t<n-1;t++)
> 		{
> 			for(i=0;i<6;i++)
> 			{
> 				for(j=0;j<N-6;j++)
> 					c[j+i]+=(a[j]*b[i]);
> 			    for(k=0;k<N-1;k++)
> 				{
> 				    c[k+1]+=(c[k]-c[k]%10)/10;
> 				    c[k]%=10;
> 				}
> 			}
> 		    for(i=0;i<N;i++)
> 			{
> 				a[i]=c[i];
> 				c[i]=0;
> 			}
> 		}//模拟乘法
> 		//输出格式
> 		for(i=0;!a[i]&&i<N;i++);
> 		left=i;
> 		if(left==N) {cout<<"0"<<endl;continue;}
> 		for(i=N-1;!a[i];i--);
> 		right=i;
>         if(left>=fl)
> 		{
> 			for(i=right;i>=fl;i--)
> 				cout<<a[i];
> 			cout<<endl;
> 		}
> 		else if(left<fl&&fl<right+1)
> 		{
> 			for(i=right;i>=fl;i--)
> 				cout<<a[i];
> 			cout<<".";
> 			for(i=fl-1;i>=left;i--)
> 				cout<<a[i];
> 			cout<<endl;
> 		}
> 		else if(fl>right)
> 		{
> 			cout<<"0.";
> 			for(i=fl-1;i>=left;i--)
> 				cout<<a[i];
> 			cout<<endl;
> 		}
> 	}
> 	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