失败尽常态 @ 2021-09-01 16:58:04
#include<bits/stdc++.h>
using namespace std;
char s1[101010],s2[101010];
int a[10010],b[100101],c[100101];
int main(){
scanf("%s",s1);
scanf("%s",s2);
int la,lb,lc;
la=strlen(s1);
lb=strlen(s2);
for(int i=0;i<la;i++){
a[la-i]=s1[i]-'0';
}
for(int i=0;i<lb;i++){
b[lb-i]=s2[i]-'0';
}
lc=la+lb;
for(int i=1;i<=lb;i++){
for(int j=1;j<=la;j++){
c[i+j-1] += a[j]*b[i];
c[i+j] +=c[i+j-1]/10;
c[i+j-1]=c[i+j-1]%10;
}
}
if(c[lc]==0&&lc>0){
lc--;
}
for(int i=lc;i>=1;i--)
cout<<c[i];
}
by WZY718605 @ 2021-09-01 17:06:03
#include<bits/stdc++.h>
using namespace std;
char s1[101010],s2[101010];
int a[10010],b[100101],c[100101];
int main(){
scanf("%s",s1);
scanf("%s",s2);
int la,lb,lc;
la=strlen(s1);
lb=strlen(s2);
for(int i=0;i<la;i++){
a[la-i]=s1[i]-'0';
}
for(int i=0;i<lb;i++){
b[lb-i]=s2[i]-'0';
}
lc=la+lb;
for(int i=1;i<=lb;i++){
for(int j=1;j<=la;j++){
c[i+j-1] += a[j]*b[i];
c[i+j] +=c[i+j-1]/10;
c[i+j-1]=c[i+j-1]%10;
}
}
while(c[lc]==0&&lc>1){
//去前导零要用while不能用if以为可能有不止一个零,lc>0改成lc>1
lc--;
}
for(int i=lc;i>=1;i--)
cout<<c[i];
}
@失败尽常态
by lonely_cyx @ 2021-09-01 17:07:30
@WZY751205 同志,他过了
by 失败尽常态 @ 2021-09-01 17:07:37
@WZY751205 确实是这个问题 我过了大佬
by lonely_cyx @ 2021-09-01 17:07:54
@WZY751205 https://www.luogu.com.cn/record/57326183
by WZY718605 @ 2021-09-01 17:10:46
@hyzhuo 多谢提醒
by lamp_forever @ 2021-09-01 17:28:07
az,本蒟蒻前来慰问@WZY751205