#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
char s[10010];
int a[50001],sth[50001],p[10];
long long b,c;
int main(){
gets(s);
scanf("%d",&b);
int len=strlen(s),th=0,xs,bbb=0;
for(int i=0;i<len;i++)a[i+1]=s[i]-'0';
int j=0;
while(th<b && j<len){
th=th*10+a[++j];
}
printf("%d",th/b);
th%=b;
for(int i=j+1;i<len;i++){
th=th*10+a[i];
printf("%d",th/b);
th%=b;
}
printf(".");
for(int i=1;i<=4;i++){
th*=10;
p[i]=th/b;
th%=b;
}
if(p[4]>=5)p[3]++;
printf("%d%d%d",p[1],p[2],p[3]);
return 0;
}
【高精度算法】A/B 高精度除以低精度 保留小数
最新推荐文章于 2024-07-29 18:40:11 发布