博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
高精度练习之乘法(codevs_3117)
阅读量:4441 次
发布时间:2019-06-07

本文共 1108 字,大约阅读时间需要 3 分钟。

#include
#include
#include
using namespace std;inline int max(int a,int b){
return a>b?a:b;}struct hpc{
int a[260],l;};hpc change(char s[]){ int len=0,l=strlen(s); hpc ans;memset(ans.a,0,sizeof(ans.a)); for(int i=l-1;i>=0;i-=4){ int t=0,k=max(i-3,0); for(int j=k;j<=i;j++) t=t*10+s[j]-'0'; ans.a[len++]=t; } ans.l=len; return ans;}void print(hpc a){ printf("%d",a.a[a.l-1]); for(int i=a.l-2;i>=0;i--) printf("%04d",a.a[i]); puts("");}hpc operator *(const hpc a,const hpc b){ hpc ans;int l; memset(ans.a,0,sizeof(ans.a)); if((a.l==1&&a.a[0]==0)||(b.l==1&&b.a[0]==0)) {ans.l=1;return ans;} for(int i=0;i
0){ ans.a[l+1]=ans.a[l]/10000; ans.a[l]%=10000; l++; } ans.l=l; return ans;}int main(){ char s[510]; scanf("%s",s);hpc a=change(s); scanf("%s",s);hpc b=change(s); a=a*b;print(a); return 0;}

本文由Yzyet编写,网址为www.cnblogs.com/Yzyet。非Yzyet同意,禁止转载,侵权者必究。

转载于:https://www.cnblogs.com/Yzyet/p/7346446.html

你可能感兴趣的文章
免费学习视频
查看>>
Winodws10 &system进程占用磁盘100%
查看>>
css样式优先级
查看>>
遇见未知的自己
查看>>
js中return;、return true、return false;区别
查看>>
关于list的一些作业
查看>>
bzoj 2818: Gcd
查看>>
bzoj千题计划316:bzoj3173: [Tjoi2013]最长上升子序列(二分+树状数组)
查看>>
JDK1.8之后匿名内部类访问方法中的局部变量不用加final修饰
查看>>
九度oj题目1521:二叉树的镜像
查看>>
java运行时内存分类
查看>>
为什么说 Git 比 SVN 更好
查看>>
CSS的定位和浮动
查看>>
Storm启动流程分析
查看>>
C++11中lock_guard和unique_lock的区别
查看>>
解决find命令报错: paths must precede expression
查看>>
LVS 手册学习
查看>>
Lua's performance
查看>>
seajs快速了解
查看>>
Java Spring MVC项目搭建(二)——项目配置
查看>>