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

这题不就是高精算N^D吗?怎么就是WA??

Posted by sphinxdwood at 2007-08-11 14:35:14 on Problem 3199
#include<stdio.h>
#include<memory.h>
int main(){
	int res[30],i,a[30],b[30],j,d,n,k;
	scanf("%d%d",&n,&d);
	while(n!=0||d!=0){
		if(d==0) printf("1\n");
		else{
			memset(a,0,sizeof(a));
			memset(b,0,sizeof(b));			
			b[1]=a[1]=n/10;
			b[0]=a[0]=n-10*(n/10);
			for(i=1;i<d;i++){
				memset(res,0,sizeof(res));
				for(j=0;j<2;j++)
					for(k=0;k<30;k++)
						res[j+k]+=a[j]*b[k];
				for(j=0;j<30;j++){
					res[j+1]+=res[j]/10;
					res[j]=res[j]%10;
				}
				for(j=0;j<30;j++) b[j]=res[j];

			}
			i=29;
			while(res[i]==0) i--;
			while(i>=0){
				printf("%d",res[i]);
				i--;
			}
			printf("\n");
		}
		scanf("%d%d",&n,&d);
	}
	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