| ||||||||||
| 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 | |||||||||
实在不明白全部数据都过了,你们说的数据也过了.但还是WA.哪位高手指点下(代码是C++ 有注释)#include<iostream.h>
#include<math.h>
#include<string.h>
const int max=5000;
int fdou(int dx) //计算R有多少位小数!!..数据只有6位长从这个得出小数有多少...
{
int k=0;
while(dx/10!=0){k++;dx=dx/10;}
return k+1;
}
void maxnumbermul(int *pa,int number,int pown) //一个数组,乘R,乘N次
{
int i,j,set;
for(i=0;i<max;i++)
pa[i]=0;
for(i=0,j=number;j>0;i++,j=j/10)
pa[i]=j%10;
set=0;
for(i=1;i<pown;i++)
for(j=0;j<max;j++)
{
pa[j]=pa[j]*number+set;
set=pa[j]/10;
pa[j]=pa[j]%10;
}
}
int main()
{
int n,i,j,k,a[max];
double r,dr;
while(cin>>r>>n)
{
if(r==0)
{
cout<<"0\n";
continue;
}
dr=r;
if(fdou((int)r)==1){j=4;r=r*10000;}
else {j=3;r=r*1000;}
j=j*n;
cout<<r<<endl;
maxnumbermul(a,(int)r,n);
for(i=max-1;a[i]==0;i--);
for(k=0;a[k]==0;k++);
if(dr<1) i=j-1; //保证<1的数字能将有意义0全输出.
for( ;i>=j;i--)
cout<<a[i];
if(j!=0)
{
if(i>=k) cout<<'.';// 后面没数字,就不要输出.了
for( ;i>=k;i--)
cout<<a[i];
cout<<endl;
}
else cout<<endl;
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator