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:请高手帮俺看看,我已经提交了六次了,还是错!!谢谢!

Posted by xuezhongsha at 2006-05-11 13:29:29 on Problem 1001
In Reply To:请高手帮俺看看,我已经提交了六次了,还是错!!谢谢! Posted by:caison at 2006-04-11 17:14:58
> #include<iostream>
> #include<string>
> #define N 500
> using namespace std;
> int c[N]={0};
> int Length(int a[]);
> void Mul(int a[],int b[]);
> int main()
> {
> 	string R,s="99.999",t="0.0";
> 	int n , m , i ,j , point;
> 	cin>>R>>n;
> 	if(R>=s||R<=t||n<=0||n>25)return 0;
> 	for(i=R.length()-1;i>=0;i--)
> 	{
> 		if(R.at(i)!='0')
> 		{
> 			i++;
> 			R=R.substr(0,i);
> 			break;
> 		}
> 	}
> 	int length=R.length();
> 	int a[N]={0},b[N]={0};
> 	for(i=0,j=length-2;i<length;i++,j--)//把R去小数点存入 a;
> 	{
> 		if (R.at(i)=='.')
> 		{
> 			point=i+1;
> 			j++;
> 		}
> 		else a[j]=b[j]=R.at(i)-48;
> 	}
> 	point=length-point;
> 	m=n-1;
> 	while(m)
> 	{
> 		Mul(a,b);
> 		for(i=Length(c)-1;i>=0;i--)
> 		{
> 			b[i]=c[i];
> 			c[i]=0;
> 		}
> 		m--;
> 	}
> 	if(Length(b)<point*n)
> 	{
> 		cout<<'.';
> 		for(i=point*n;i>Length(b);i--)
> 			cout<<0;
> 	}
> 	for(i=Length(b)-1;i>=0;i--)
> 	{
> 		if(i==(point*n-1))
> 		{
> 			cout<<".";
> 			point=0;
> 			i++;
> 		}
> 		else
> 			cout<<b[i];
> 	}
> 	cout<<endl;
> 	return 0;
> }
> void Mul (int a[],int b[])
> {
> 	
> 	int i , j , k , x , y , z;
> 	int length_a=Length(a);
> 	int length_b=Length(b);
> 	for( i=0;i<length_a;i++)
> 	{
> 		for(j=0;j<length_b;j++)
> 		{
> 			x=a[i]*b[j];
> 			y=x/10;
> 			z=x%10;
> 			k=i+j;
> 			c[k]+=z;
> 			c[k+1]=c[k+1]+y+c[k]/10;
> 			c[k]=c[k]%10;
> 		}
> 	}
> 	k=length_a+length_b-1;
> 	if(c[k]==0)k--;
> }
> int Length(int a[])
> {
> 	int i=N-1;
> 	while(!a[i]&&i>=0)
> 		i--;
> 	return i+1;
> }
> 
> 	是不是要把全部的数据在程序一次执行就处理完才行啊?? 

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