P1303 A*B Problem 高精度乘法
生活随笔
收集整理的這篇文章主要介紹了
P1303 A*B Problem 高精度乘法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
復習了一下高精乘
#include<bits/stdc++.h> using namespace std; const int maxn=1e6+7; char a1[maxn],b1[maxn]; int a[maxn],b[maxn],c[maxn*10],lena,lenb,lenc,x; int main() {scanf("%s",a1);scanf("%s",b1);lena=strlen(a1);lenb=strlen(b1);for(int i=0;i<lena;i++) a[lena-i]=a1[i]-'0';for(int i=0;i<lenb;i++) b[lenb-i]=b1[i]-'0';for(int i=1;i<=lena;i++){x=0;for(int j=1;j<=lenb;j++){c[i+j-1]=a[i]*b[j]+x+c[i+j-1];x=c[i+j-1]/10;c[i+j-1]%=10;}c[i+lenb]=x;}lenc=lena+lenb;while(c[lenc]==0&&lenc>1) lenc--;for(int i=lenc;i>=1;i--) cout<<c[i];return 0; }?
轉載于:https://www.cnblogs.com/LJB666/p/10995752.html
總結
以上是生活随笔為你收集整理的P1303 A*B Problem 高精度乘法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Go信号gsignal和宿主Signal
- 下一篇: MIP 技术交流分享(3月15日)