FFT
#include<iostream> #include<cstdlib> #include<cmath> #include<cstring> #include<cstdio> #include<algorithm> #include<string> #include<map> #include<queue> #include<vector> #include<set> #define inf 1000000000 #define maxn 200000+5 #define maxm 10000+5 #define eps 1e-10 #define ll long long #define for0(i,n) for(int i=0;i<=(n);i++) #define for1(i,n) for(int i=1;i<=(n);i++) #define for2(i,x,y) for(int i=(x);i<=(y);i++) #define for3(i,x,y) for(int i=(x);i>=(y);i--) #define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go) using namespace std; int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=10*x+ch-'0';ch=getchar();} return x*f; } struct cp{ double x,y; inline cp operator +(cp b){return (cp){x+b.x,y+b.y};} inline cp operator -(cp b){return (cp){x-b.x,y-b.y};} inline cp operator *(cp b){return (cp){x*b.x-y*b.y,x*b.y+y*b.x};} }; const double PI=acos(-1.0); cp a[maxn],b[maxn],c[maxn],y[maxn]; int n,m,len,rev[maxn],ans[maxn]; char s[maxn]; void fft(cp *x,int n,int flag){ for0(i,n-1)y[rev[i]]=x[i]; for0(i,n-1)x[i]=y[i]; for(int m=2;m<=n;m<<=1){ cp wn=(cp){cos(2.0*PI/m*flag),sin(2.0*PI/m*flag)};//w£¨m£¬1£© for(int i=0;i<n;i+=m){ cp w=(cp){1.0,0};int mid=m>>1; for0(j,mid-1){ cp u=x[i+j],v=x[i+j+mid]*w; x[i+j]=u+v;x[i+j+mid]=u-v; w=w*wn; } } } if(flag==-1)for0(i,n-1)x[i].x/=n; } int main(){ //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); n=read(); scanf("%s",s); for0(i,n-1)a[i].x=s[n-1-i]-'0'; scanf("%s",s); for0(i,n-1)b[i].x=s[n-1-i]-'0'; m=1;n=2*n-1; while(m<=n)m<<=1,len++;n=m; for0(i,n-1){ int t=i,ret=0; for1(j,len)ret<<=1,ret|=t&1,t>>=1; rev[i]=ret; } fft(a,n,1);fft(b,n,1); for0(i,n-1)c[i]=a[i]*b[i]; fft(c,n,-1); for0(i,n-1)ans[i]=c[i].x+0.5; for0(i,n-1)ans[i+1]+=ans[i]/10,ans[i]%=10; n++; while(!ans[n]&&n)n--; for3(i,n,0)putchar('0'+ans[i]); return 0; }