【高精度算法】A*B 加强版
来源:互联网 发布:解压软件怎么安装 编辑:程序博客网 时间:2024/05/21 22:22
#include<stdio.h>#include<stdlib.h>#include<string.h>char s[30001];long long a[15000],b[15000],c[50001];int main (){ int alen,blen,clen; int i,j,k,m,n; gets(s); alen=strlen(s); k=0; for(i=alen-1;i>=0;i-=3){ long long tmp=0; int start; start=i-2; if(start<0)start=0; for(j=start;j<=i;j++) tmp=tmp*10+s[j]-'0'; a[++k]=tmp; } alen=k; gets(s); blen=strlen(s); k=0; for(i=blen-1;i>=0;i-=3){ long long tmp=0; int start; start=i-2; if(start<0)start=0; for(j=start;j<=i;j++) tmp=tmp*10+s[j]-'0'; b[++k]=tmp; } blen=k; for(i=1;i<=alen;i++) for(j=1;j<=blen;j++) c[i+j-1]+=a[i]*b[j]; clen=alen+blen; while(c[clen]==0 && clen>1) clen--; for(i=1;i<clen;i++) if(c[i]>=1000){ c[i+1]+=c[i]/1000; c[i]%=1000; } printf("%lld",c[clen]); for(i=clen-1;i>=1;i--){ if(c[i]<10)printf("00"); else if(c[i]<100)printf("0"); printf("%lld",c[i]);} return 0;}
0 0
- 【高精度算法】A*B 加强版
- 【高精度算法】A+B 加强版
- 【高精度算法】A*B
- 【高精度算法】A+B
- 【高精度算法】A+B
- 【高精度算法】A/B 高精度初以高精度保留余数
- 【高精度算法】A/B 高精度除以低精度 保留小数
- 人见人爱A^B 数据加强版
- 【BZOJ3767】A+B Prlblem加强版
- 3767: A+B Problem加强版
- bzoj3767 A+B Problem加强版
- 1381 a*b 高精度
- 高精度大数A+B
- A+B Problem 高精度
- A + B高精度
- a+b(高精度)
- 高精度 A*B Problem
- 高精度 A+B Problem
- office tab插件
- 随手记SharedSDK
- js禁止输入特殊字符
- ORA-1555,oracle读一致性
- web.py服务端,jquery ajax简单例子
- 【高精度算法】A*B 加强版
- 织梦tag标签显示每个标签相应的文章数量的方法
- C#写入和读出文本文件
- Core Animation 之 CALayer
- hdu 2309 ICPC Score Totalizer Software
- MySQL Split String Function
- android,去掉标题栏+++全屏显示
- Android 通过ViewPager实现广告轮播效果
- 【高精度算法】A+B