Loj515 「LibreOJ β Round #2」贪心只能过样例

bitset的基本应用了

类似可行性背包的dp考虑

复杂度O(nmL/64)

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 bitset <1000005> bs,bs0;
 5 
 6 int n,a,b;
 7 
 8 int main(){
 9     ios::sync_with_stdio(false);
10     cin>>n;
11     bs[0]=1;
12     for(int i=1;i<=n;i++){
13         bs0=bs; bs.reset();
14         cin>>a>>b;
15         for(int j=a;j<=b;j++)
16             bs|=(bs0<<(j*j));
17     }
18     cout<<bs.count();
19 }
原文地址:https://www.cnblogs.com/mollnn/p/8443334.html