| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
3199一直WA,麻烦各位帮看下吧,谢了!实在想不出来了!太谢谢了!
#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator