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

哪位前辈帮忙看下代码,我试了很多数据了但还是不过,帮帮忙,给个数

Posted by 271314 at 2010-11-09 23:12:29 on Problem 1001
#include<iostream>
#include<string.h>
using namespace std;
//考虑下小数点的问题
int main()
{
	int i,j,n,q;char r[100];int d=0,o=1;
	while(cin>>r)
	{int w=-1;
	cin>>n;
		j=strlen(r);//不读入回车
	q=j;
	 if(n==0)
		cout<<"1";
	else
	{ 
	int e[1000]={0},e1[1000]={0},e2[1000]={0};d=q;int y;
	for(i=0;i<d;i++)
	{
		
	    if(r[q-i-1]=='.')
	    { 
		w=i;q--;
		}//注意赋值
	     if(q-i-1<0) break;//检查数组越界
		
		e2[i]=e[i]=(r[q-i-1]-'0');		
	}
	w=w*n+1;//记入小数点输出位置	
int c=0,k;
if(n==1)
	{
	    
	     o=0;
	}
if(n>=2)
{
for(i=0;i<n-1;i++)
{
	
	for(k=0;k<d;k++)
	{  q=k;
     	for(j=0;j<1000;j++)
		{
		int s=e[j]*e2[k]+c+e1[q];
		c=0;
		e1[q]=s%10;
		c=s/10;
		q++;
		}
	}
	for(int y=0;y<1000;y++)
	{e[y]=e1[y];e1[y]=0;}
}
}
d=0;q=1;
for(i=0;i<1000;i++)
{   if(e[0]!=0) break;
	if(e[i]!=0) q=0;
	if(e[i]==0&&q&&i<=w-2) d++;
}
 q=1;j=1;k=1;
for(i=998;i>=d;i--)
{   
	if(e[i]!=0)
	{ q=0;y=i;}
	//if(y<w&&j)
	//{	cout<<"0";j=0;}
	if(i==w-2)
	{
	cout<<".";k=0;
		}
    if(e[i]==0&&k&&q)
		continue;
	//if(i!=(1000-y-w))
	cout<<e[i];}
}
	if(q==1&&o)
		cout<<"0";
cout<<"\n";
	}
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