高精度乘法加强
来源:互联网 发布:二叉树的遍历算法代码 编辑:程序博客网 时间:2024/04/29 08:06
转自http://blog.csdn.net/cm_yali/article/details/50607751
#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
- 高精度乘法加强
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 高精度乘法
- 贪吃蛇
- Android 第八天(下午)
- hdu 5199 Gunner【水题】【STL应用】【fast IO】
- RtlUnicodeStringInit function
- Android 动画 ValueAnimator(四)
- 高精度乘法加强
- iOS 9 学习系列: Search APIs
- 那些情况该使用它们spin_lock到spin_lock_irqsave
- BZOJ 4002 JLOI 2015 有意义的字符串 数列
- 【Python 笔记】Python中 swich...case 的实现
- mybaits错误解决:There is no getter for property named 'id' in class 'java.lang.Long'
- bzoj 1002
- JS分离构造器
- 修改debian的时间,pst 修改到cst 北京/上海时区