Loj515 「LibreOJ β Round #2」贪心只能过样例 - Bitset,Dp

时间:2023-03-10 07:11:36
Loj515 「LibreOJ β Round #2」贪心只能过样例 - Bitset,Dp

bitset的基本应用了

类似可行性背包的dp考虑

复杂度O(nmL/64)

 #include <bits/stdc++.h>
using namespace std; bitset <> bs,bs0; int n,a,b; int main(){
ios::sync_with_stdio(false);
cin>>n;
bs[]=;
for(int i=;i<=n;i++){
bs0=bs; bs.reset();
cin>>a>>b;
for(int j=a;j<=b;j++)
bs|=(bs0<<(j*j));
}
cout<<bs.count();
}