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

来源:互联网 发布:visual attention知乎 编辑:程序博客网 时间:2024/06/06 05:35

题目链接:https://loj.ac/problem/515

解法:记录 LibreOJ的第一个题,直接bitset暴力即可。

#include <bits/stdc++.h>using namespace std;const int maxn = 1e6+10;int n, l, r;bitset <maxn> b[110];int main(){    while(~scanf("%d", &n)){        b[0].set(0);        for(int i=1; i<=n; i++){            b[i].reset();            scanf("%d %d", &l,&r);            for(int j=l; j<=r; j++){                b[i]|=(b[i-1]<<(j*j));            }        }        printf("%d\n", b[n].count());    }    return 0;}
阅读全文
0 0
原创粉丝点击