| dn += f[n][i]*a[n-i]; file://计算dn } dn = dn % 2; file://取余 // cout <<"d"<<n<<"= "<<dn <<endl; int isum = 0; for (int i =0;i<=n ;++i) { isum +=l[i]; file://判定是不是所有的ln都等于0就是把所有的ln加起来看是不是零 } if( dn == 0) file://如果dn =0 { f.push_back(f[n]); file://fn+1 = fn l.push_back(l[n]); file://ln+1 = ln } else if (!isum) file://所有的ln都是零 { temp.clear(); for(int i =0;i<n+2;++i) { temp.push_back(0); } temp[0] = 1; temp[n+1] = 1; f.push_back(temp); l.push_back(n+1); } else file://lm<lm+1 = ...=ln { int m =0; for (int i = n;i>=0; --i) { if(l[i]<l[n]) { m= i; file://找到m break; } }//end for temp.clear();//把临时的目的数组清空 for (int i =0;i<n-m;++i) { temp.push_back(0); file://fm乘x^n-m次方就是在多项式数组前面插入n-m个零 } temp.insert(temp.end(),f[m].begin(),f[m].end()); file://构造fm*x^n-m vector<bool> ft; file://用来保存两个多项式相加的结果 int len = max(temp.size(),f[n].size()); file://取出多项式系数最大值 ft.insert(ft.begin(),len,0); file://把目的数组填入len个零初始化 for (int i = 0 ;i<temp.size(); ++i) |