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 哪位老大帮看一下,谢了。

Posted by coolfish2006 at 2006-05-03 12:54:41
#include <iostream>

using namespace std;

int main()
{
	double r;
	int n;
	int j;

	while(cin>>r>>n)
	{
		int counter = 0;
		unsigned long thenum;
		thenum = (unsigned long)(r*100000);

		while(thenum%10==0)
		{
			thenum/=10;
			counter++;
			if(counter == 5) break;
		}

		counter = 5-counter;
		counter*=n;

		unsigned long add[34]={0};
		add[0] = thenum;

		for(int k = 0;k<n-1;k++)
		{
			for(j=0;j<33;j++)
			{
				if(add[j]>9999)
				{
					add[j+1] += (unsigned long)(add[j]/10000);
					add[j] = (unsigned long)(add[j]%10000);
				}
			}
			for(j=0;j<34;j++)
			{
				add[j]*=thenum;
			}

		}

		for(j=0;j<33;j++)
		{
			if(add[j]>9999)
			{
				add[j+1] += (unsigned long)(add[j]/10000);
				add[j] = (unsigned long)(add[j]%10000);
			}
		}

		int a[34*4]={0};

		for(k=0;k<34;k++)
		{
			for(j=0;j<4;j++)
			{
				a[4*k+j] = add[k]%10;
				add[k] = add[k]/10;
			}
		}

		int flag = 0;
		for(k=34*4-1;k>=counter;k--)
		{
			if(flag == 0 && a[k] == 0) continue;
			else
			{
				cout << a[k];
				flag = 1;
			}
		}
		if(counter!=0) cout << ".";
		for(k=counter-1;k>=0;k--)
		{
			cout << a[k];
		}
		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