版本比较
多项式
正文
增加 32 行删除 6 行
66 行未改动67686970717172737475330 行未改动全部展开40640740840941041041141241341441541641741741841942042115 行未改动43743843944044144144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447544844966 行未改动{public: vector<int>val; Poly()=default; explicit Poly(int siz):val(siz,0){} explicit Poly(int siz,int v=0):val(siz,v){} Poly(const vector<int>& v):val(v){trim();} size_t size()const{return val.size();} int operator()(const int x)const {330 行未改动全部展开 Poly res(fa); res.trim(); return res; } friend Poly operator<<(const Poly& a,int k) friend Poly operator<<(const Poly& a,size_t k) { Poly res; res.resize(k); for(auto x:a.val)res.val.push_back(x); return res; } friend Poly operator>>(const Poly& a,int k) friend Poly operator>>(const Poly& a,size_t k) { Poly res; for(int i=k;i<(int)a.size();++i)res.val.push_back(a[i]); res.trim();15 行未改动 { for(int v:p.val)out<<v<<' '; return out; } auto operator+=(const Poly& b){} auto operator +=(const Poly& b){*this=*this+b;return *this;} auto operator -=(const Poly& b){*this=*this-b;return *this;} auto operator *=(const Poly& b){*this=*this*b;return *this;} auto operator /=(const Poly& b){*this=*this/b;return *this;} auto operator %=(const Poly& b){*this=*this%b;return *this;} auto operator |=(const Poly& b){*this=*this|b;return *this;} auto operator &=(const Poly& b){*this=*this&b;return *this;} auto operator ^=(const Poly& b){*this=*this^b;return *this;} auto operator<<=(const size_t& b){*this=*this<<b;return *this;} auto operator>>=(const size_t& b){*this=*this>>b;return *this;}};signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin>>T; map<pair<int,int>,int>mp; while(T--) { int n,k; cin>>n>>k; if(mp.count({n,k})) { cout<<mp[{n,k}]<<'\n'; continue; } Poly a(10,1); Poly b=a.pow(n,k+1); int ans=0; for(auto p:b.val)ans+=p; mp[{n,k}]=ans-1; cout<<ans-1<<'\n'; }}
```