Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
111572 吴宗桦 万进制高精度运算 C++ 运行超时 0 1000 MS 940 KB 1566 2023-11-22 16:46:16

Tests(0/100):


#include<iostream> #include<cstdio> #include<cstring> using namespace std; int a[50005],b[50005],c[50005],a2,b2,c2,x,d,e; bool p; char a1[50005],b1[50005],c1[50005]; int main() { cin>>a1>>b1; int len1=strlen(a1); int len2=strlen(b1); for(int i=1;i<=len1;i++) a[i]=a1[len1-i]-'0'; for(int i=1;i<=len2;i++) b[i]=b1[len2-i]-'0'; int len3=1; int x=0; while(len3<=len1||len3<=len2) { c[len3]=a[len3]+b[len3]+x; x=c[len3]/10; c[len3]%=10; len3++; } c[len3]=x; while(c[len3]==0&&len3>1) len3--; for(int i=len3;i>=1;i--) cout<<c[i]; cout<<endl; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); a2=strlen(a1);b2=strlen(b1); for(x=0;x<=a2-1;x++)a[a2-x]=int(a1[x]-'0'); for(x=0;x<=b2-1;x++)b[b2-x]=int(b1[x]-'0'); x=1; while(x<=a2||x<=b2) { if(a[x]<b[x]) { a[x]+=10; a[x+1]--; } c[x]=a[x]-b[x]; x++; } c2=x; while(c[c2]==0&&c2>1) c2--; for(x=c2;x>=1;x--) cout<<c[x]; cout<<endl; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); a2=strlen(a1);b2=strlen(b1); if(a1[0]=='-') p=0; if(b1[0]=='-') if(p==1) p=0;else p=1; for(d=0;d<=a2-1;d++) a[a2-d]=a1[d]-48; for(d=0;d<=b2-1;d++) b[b2-d]=b1[d]-48; for(d=1;d<=a2;d++) { x=0; for(e=1;e<=b2;e++) { c[d+e-1]=a[d]*b[e]+x+c[d+e-1]; x=c[d+e-1]/10; c[d+e-1]%=10; } c[d+b2]=x; } c2=a2+b2; while(c[c2]==0&&c2>1) c2--; for(d=c2;d>=1;d--) cout<<c[d]; cout<<endl; return 0; }