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

为什么是WRONG ANSWER,,,,,,谁来告诉我撒??疯掉了

Posted by 1006840622 at 2013-03-05 11:57:28 on Problem 1001
#include <iostream>
using namespace std;
int R;
int n;
int h;
int dot_index;
char s[6];
int r_int[125];
 void power(int r[],int R)
 {
	 for(int i=0;i<=h;i++)
	 {
		 r[i]*=R;
	 }
	 int i=0;
	 while(i<h)
	 {
		 r[i+1]+=r[i]/10;
		 r[i]=r[i]%10;
		 i++;
	 }
	 while(r[i]/10!=0)//critical
	 {
		 r[i+1]+=r[i]/10;
		 r[i]=r[i]%10;
		 i++;
	 }
	 h=i;
 }
 int main()
 {
	 n=0;
	 while(cin>>s>>n)
	 {
		 R=0;h=0;dot_index=0;
		 for(int i=0;i<5;i++)
		 {
			 if(s[i]=='.')
				 dot_index=(5-i)*n-1;
		 }
		 
		 for(int i=0;i<=5;i++)
		 {
			 if(s[i]!='.')
				 R=R*10+(s[i]-'0');
		 }
		
		 
		 if(R==0)
		 {
			 cout<<0<<endl;
			 continue;
		 }

		 memset(r_int,0,sizeof(r_int));
		 r_int[0]=1;
		 for(int i=0;i<n;i++)
			 power(r_int,R);
		 int trail=0;
		 if(dot_index!=0)
		 {
			for(;trail<=dot_index;trail++)
			 {
				if(r_int[trail]!=0)
					break;
			 }
		 }
		 for(;h>=trail;h--)
		 {
			 if(dot_index==h)
				 cout<<".";
			 cout<<r_int[h];
		 }
		 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