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

谁给看看下面这个程序哪错了?discuss里所有的测试数据都对,非常感谢

Posted by lingd at 2008-06-08 15:58:08 on Problem 1001 and last updated at 2008-06-08 15:59:19
In Reply To:WA超过十遍了,Discuss中所有的测试数据都对了,还是WA。。。。。。 Posted by:lingd at 2008-06-08 15:17:58
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void Multiply(short *buf,int i,int length,long multi,long carry)
{
	long temp;
	if(i>=length)
		return;
	temp=buf[i]*multi+carry;
	buf[i]=temp%10;
	Multiply(buf,i+1,length,multi,temp/10);
}

void main()
{
	short buf[500];
	long data;
	long tempdata;
	double input;
	int trailingzero,leadingzero;
	int n;
	int i;
	short residue;

	while(scanf("%lf%d",&input,&n)==2)
	{
		if(n==0)
		{
			printf("1\n");
			continue;
		}

		if(input==0.0)
		{
			printf("0\n");
			continue;
		}

		data=(long)(input*100000);

		memset(buf,0,500*sizeof(short));
		i=0;
		tempdata=data;
		while(1)
		{
			residue=tempdata%10;
			buf[i]=residue;
			i++;
			tempdata=tempdata/10;
			if(tempdata==0)
				break;
		}


		for(i=1;i<n;i++)
			Multiply(buf,0,i*10+10,data,0);

		for(i=0;i<5*n&&buf[i]==0;i++);
		trailingzero=i;
		for(i=10*n-1;i>(5*n-1)&&buf[i]==0;i--);
		leadingzero=i;
		for(i=leadingzero;i>=trailingzero;i--)
		{
			if(i==5*n-1)
				printf("%c",'.');
			printf("%d",buf[i]);
		}
		printf("\n");
	}
}

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