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

贴下我的代码,不过这代码在hdoj上AC不了,hdoj数据很强大,我A不了

Posted by sunkuo at 2013-01-08 18:24:49 on Problem 1001
In Reply To:快哭了,怎么就是wa,我所有数据都试过了 Posted by:sunkuo at 2013-01-08 13:53:15
#include<iostream>
using namespace std;
int find_point(char a[])
{
	int i;
	for(i=0;i<6;i++)
		if(a[i]=='.')break;
	return i;
}

void multi(int answer[],int num,int &answer_len)
{
	int c=0;
	for(int i=0;i<answer_len;i++)
	{
		int s=(answer[i]*num+c);
		answer[i]=s%10;
		c=s/10;
	}
	while(c)
	{
		answer[answer_len++]=c%10;
		c/=10;
	}
}


int main()
{
	int answer[150]={0};
	int plus[10];
	char R[10];
	int n;
	while(cin>>R>>n)
	{
		memset(answer,0,sizeof(answer));
		memset(plus,0,sizeof(plus));
		int point_locate=find_point(R);
		int point_digit=(5-point_locate)*n;
		int len=0;
		for(int i=5;i>=0;i--)
		{
			if(R[i]!='.')
			answer[len++]=plus[len]=R[i]-'0';
		}
		//cur=6  answer  5 digit;
		if(plus[1]==0&&plus[2]==0&&plus[3]==0&&plus[4]==0&&plus[0]==0)
		{
			cout<<'0'<<endl;
			continue;
		}
		if(n==0)
		{
			cout<<'1'<<endl;
			continue;
		}
		for(int i=0;i<n-1;i++)
		{
			int num=plus[0]+plus[1]*10+plus[2]*100+plus[3]*1000+plus[4]*10000;
			multi(answer,num,len);
		}

		

		int flag;
		flag=len-1;
		for(;flag>=point_digit;flag--)
			if(answer[flag])break;

		for(int i=flag;i>point_digit-1;i--)
			cout<<answer[i];

		flag=0;
		for(;;){
			if(answer[flag])break;
			flag++;
		}

		if(flag<point_digit)
		     cout<<'.';
		
		for(int i=point_digit-1;i>=flag;i--)
			cout<<answer[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