nbdog @ 2024-08-14 17:38:25
代码
求大佬在源代码上改
by lxr_Galaxy @ 2024-08-14 17:39:07
这题高精
by lxr_Galaxy @ 2024-08-14 17:40:38
我把我源代码复制上去了 @lijunxian__8133
by nbdog @ 2024-08-14 17:40:54
@lxr_Galaxy
何为高精?甚是不解。
by lxr_Galaxy @ 2024-08-14 17:42:21
@lijunxian__8133 高精度,这题数据范围太大了,long long也存不下,高精就是把整型的问题转换成string和数组来求取答案
by nbdog @ 2024-08-14 17:43:22
@lxr_Galaxy
无敌了,被人设密码了,大佬还是直接告诉我把!
by lxr_Galaxy @ 2024-08-14 17:44:04
#include<iostream>
#include<cstring>
using namespace std;
int main(){
char a_str[2005]={};
char b_str[2005]={};
cin>>a_str>>b_str;
int a[2005]={},b[2005]={};
int len_a=strlen(a_str),len_b=strlen(b_str);
for(int i=0;i<=len_a-1;i++){
a[len_a-i-1]=a_str[i]-48;
}
for(int i=0;i<=len_b-1;i++){
b[len_b-i-1]=b_str[i]-48;
}
int ans[4010]={};
int in=0;
for(int j=0;j<=len_b-1;j++){
for(int i=0;i<=len_a-1;i++){
ans[i+j]=a[i]*b[j]+in+ans[i+j];
in=ans[i+j]/10;
ans[i+j]%=10;
}
ans[len_a+j]=in;
in=0;
}
int len_ans=len_a+len_b;
while(ans[len_ans-1]==0 && len_ans>1){
len_ans--;
}
for(int i=len_ans-1;i>=0;i--){
cout<<ans[i];
}
}
by nbdog @ 2024-08-14 17:47:13
@lxr_Galaxy
哇!大佬在上,受小弟一拜!总之灰常感谢!
by lxr_Galaxy @ 2024-08-14 17:48:18
@lijunxian__8133 不客气哦
by nbdog @ 2024-08-14 18:06:14
@lxr_Galaxy
厉害!大佬不仅知识渊博而且人品还好!已关
by nbdog @ 2024-08-14 18:06:59
@lijunxian__8133
OK!此贴结!