| ||||||||||
| 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 | |||||||||
不是说不能贴代码吗 ?In Reply To:偶没时间帮你看,你看一下我的吧 Posted by:ecjtubaowp at 2007-01-13 17:21:54 > #include<stdio.h>
> int main()
> {
> int i,j,k,n,m,a,D,tp,h[200],c[200],t[200];
> char b[10];
> while(scanf("%s%d",b,&n)!=EOF)
> {
>
> a=0;D=0;
> char *p=b;
>
> while(*p!='.')
> {a=a*10+*p-'0';p++;}
> char *q=p;
> while(*p!='\0')
> p++ ;
> p--;
> while(*p=='0')
> {p--;}
> *(p+1)='\0';q++;
> while(*q!='\0')
> {a=a*10+*q-48;q++;D++;}
> //printf("%d %d\n",a,D);
> k=0;
> while(a!=0)
> {
> m=a%10;a/=10;c[k]=m;k++;
> }
> D*=n;
> n--;tp=k-1;
> for(i=0;i<k;i++)h[i]=c[i];
>
> while(n--)
> {
> for(i=0;i<200;i++)t[i]=0;
>
> for(i=0;i<=tp;i++)
> {
> for(j=0;j<k;j++)
> {
> t[i+j]=t[i+j]+c[j]*h[i];
> t[i+j+1]=t[i+j+1]+t[i+j]/10;
> t[i+j]=t[i+j]%10;
>
> }
>
> }
> tp=t[k+tp]==0?tp+k-1:tp+k;
> for(i=0;i<=tp;i++)h[i]=t[i];
>
>
> }
> /*for(i=tp;i>=0;i--)
> printf("%d",h[i]);
>
>
> */
> //printf("%d",tp);
> if(D==0)
> {
> for(i=tp;i>=0;i--)printf("%d",h[i]);
> printf("\n");
> continue;
> }
> if(tp>=D)
> {
> for(i=tp;i>=D;i--)printf("%d",h[i]);
> printf(".");
> for(i=D-1;i>=0;i--)printf("%d",h[i]);
> printf("\n");
> }
> else
> {
> if(D==tp+1)
> {
> printf(".");
> for(i=tp;i>=0;i--)printf("%d",h[i]);
> printf("\n");
> }
> else
> {
> printf(".");
> for(i=1;i<=D-tp-1;i++)printf("0");
> for(i=tp;i>=0;i--)printf("%d",h[i]);printf("\n");
> }
> }
>
>
> }
> return 0;
> }
>
> /*
> Sample Input
>
>
> 95.123 12
> 0.4321 20
> 5.1234 15
> 6.7592 9
> 98.999 10
> 1.0100 12
>
> Sample Output
> 548815620517731830194541.899025343415715973535967221869852721
> .00000005148554641076956121994511276767154838481760200726351203835429763013462401
> 43992025569.928573701266488041146654993318703707511666295476720493953024
> 29448126.764121021618164430206909037173276672
> 90429072743629540498.107596019456651774561044010001
> 1.126825030131969720661201
> */
>
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator