0%

思路讲解

使用FFT。

注意给FFT喂入的是从低到高的。

输出前注意去除前导0。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
string A,B;
cin>>A>>B;
vll a,b;
ROF(i,SZ(A)-1,0){
a.pb(A[i]-'0');
}
ROF(i,SZ(B)-1,0){
b.pb(B[i]-'0');
}
vll ans=multiply(a, b);
ll carry=0;
FOR(i,0,SZ(ans)-1){
ans[i]+=carry;
carry=ans[i]/10;
ans[i]%=10;
}
while (!ans.empty() && ans.back()==0) {
ans.pop_back();
}
if(SZ(ans)==0){
cout<<0;
return;
}
ROF(i,SZ(ans)-1,0){
cout<<ans[i];
}

AC代码

https://www.luogu.com.cn/record/229526218

心路历程(WA,TLE,MLE……)

思路讲解

https://www.bilibili.com/video/BV1za411F76U/

AC代码

https://www.luogu.com.cn/record/229525769

心路历程(WA,TLE,MLE……)

那么WA了几发,发现是因为这个多项式乘法他要求的输出个数是N+M。

不用去除后导0。

思路讲解

这个检查器还是有点难想到怎么样去写的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
auto check=[&](ll mid){
bool oka=false,okb=false;;
FOR(i,0,mid){
if(cnta[i]==0){
oka=true;
}
if(cntb[i]==0){
okb=true;
}
}
if(oka && okb){
return true;
}
ll cnt=0;
FOR(i,0,mid){ // 只要不是强制的,一定可以让i都在A中,或者i都在b中
if(!forced[i]) ++cnt;
}
if(cnt>=2) return true;
return false;
};

AC代码

心路历程(WA,TLE,MLE……)

思路讲解

https://www.codechef.com/viewsolution/1179874822

我们的贪心做法用AI树状数组给过去了(其实我也想到了,但是我觉得复杂度也太离谱了吧,就没试)。

my solution is a kind of greedy.

It is not difficult to observe that delete the last element matched is the best, because it affect the least elements.

so just do it.

certainly, using vector or list can not go through all tests.

but if you using fenwick tree which can find the kth element, all problems will be solved.

AC代码

https://www.codechef.com/viewsolution/1179893708

心路历程(WA,TLE,MLE……)