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

3199一直WA,麻烦各位帮看下吧,谢了!实在想不出来了!

Posted by testdirk at 2007-02-08 02:30:36
太谢谢了!
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
	int n[20000],d[20000];
	int mid[20000],r[20000],result[20000];
	int total=1;
	int count,l;
	int i,j,k,p,ltemp,temp;
	scanf("%d %d",&n[total],&d[total]);
	while (!(n[total]==0 && d[total]==0) )
	{
		if (d[total]==0 || n[total]==0) {
			printf("1\n");
			p++;
			total++;
			scanf("%d %d",&n[total],&d[total]);
			continue;
		}
		i=1;
		k=1;
		while ((n[total]/k)>=1) {
			k*=10;
			i++;
		}
		i--;
		l=i;
		k/=10;
		mid[0]=0;
		r[0]=0;
		for (i=1;i<=l;i++) {
			r[i]=n[total]/k;
			n[total]-=r[i]*k;
			k=k/10;
		}
		for (i=1;i<=l/2;i++) {
			temp=r[i];
			r[i]=r[l-i+1];
			r[l-i+1]=temp;
		}  
		for (i=1;i<=l;i++) mid[i]=r[i];
		if (l==1) {
			for (i=1;i<=l;i++) result[i]=r[i];
			ltemp=l;
		}
		ltemp=l;
		for (i=2;i<=d[total];i++)
		{
			for (j=1;j<=l*(d[total]+1);j++) result[j]=0;
			for (j=1;j<=ltemp;j++)
				for (k=1;k<=l;k++)
				{
					result[j+k-1]+=mid[j]*r[k];
					while (result[j+k-1]>9) {
						result[j+k]+=result[j+k-1]/10;
						result[j+k-1]%=10;
					}
				}
			if (result[ltemp+l]!=0) ltemp=ltemp+l;
			else ltemp=ltemp+l;
			for (j=1;j<=ltemp;j++)
				mid[j]=result[j];
		}
		for (i=ltemp;i>=1;i--) if (result[i]!=0) break;
		for (;i>=1;i--) printf("%d",result[i]);
		printf("\n");
		total++;
		scanf("%d %d",&n[total],&d[total]);
		
	}
	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