首页 > 其他 > 详细

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

时间:2018-02-11 23:07:12      阅读:186      评论:0      收藏:0      [点我收藏+]

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 }

 

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

原文:https://www.cnblogs.com/mollnn/p/8443334.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!