HuangSiHan3116 @ 2024-07-18 22:38:38
特垃圾,有办法改吗?
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int a,b;
cin>>a>>b;
printf("%lld",a*b);
return 0;
}
by HuangSiHan3116 @ 2024-07-18 23:04:15
@LionBlaze Python不会
by wizard(偷开O2 @ 2024-07-18 23:07:21
@Hsh663116 不会就去学
给你甩个link
by _zuoqingyuan @ 2024-07-18 23:19:25
转化为多项式然后 FFT
by 水星湖 @ 2024-07-18 23:27:35
@Hsh663116 好像可以用fft吧
by Ahws_rwhy @ 2024-07-19 07:37:42
@Hsh663116 嗯嗯
by LionBlaze @ 2024-07-19 09:22:15
可以用 FFT,所以:
by fth114514 @ 2024-07-19 13:41:35
用prthon
a=int(input())
b=int(input())
print(a*b)
by fth114514 @ 2024-07-19 13:42:25
@fth114514 python打错了
by Gfx7894560123 @ 2024-07-20 21:11:33
我附上代码:
#include<bits/stdc++.h>
using namespace std;
string tim(string a,string b){
if(a=="0"||b=="0") return "0";
int l1=a.size(),l2=b.size(),x=0;
string ans(l1+l2-1,'0');
for(int i=l1-1;i>=0;i--){
x=0;
for(int j=l2-1;j>=0;j--){
int c1=a[i]-'0',c2=b[j]-'0';
x+=c1*c2+ans[i+j]-'0';
ans[i+j]=x%10+'0';
x/=10;
}
if(i) ans[i-1]+=x;
}
if(x) ans=to_string(x)+ans;
return ans;
}
int main()
{
cin.tie(nullptr)->sync_with_stdio(0);
string a,b;
cin>>a>>b;
cout<<tim(a,b);
return 0;
}
by xieyuhan666 @ 2024-07-21 10:55:51
其实可以打表