标签:bsp names main bre void amp etc ber eset
二次联通门 : LibreOJ #515. 「LibreOJ β Round #2」贪心只能过样例
/* LibreOJ #515. 「LibreOJ β Round #2」贪心只能过样例 很显然 贪心方程哦不 dp方程为 f[i][j]=f[i-1][j-k*k] 但是这样的话复杂度就是O(N ^ 5) 那么就用bitset优化一下 就ok了 */ #include <iostream> #include <cstdio> #include <bitset> void read (int &now) { register char word = getchar (); for (; !isdigit (word); word = getchar ()); for (now = 0; isdigit (word); now = now * 10 + word - ‘0‘, word = getchar ()); } #define Max 1000900 using namespace std; bitset <Max> number[110]; int main (int argc, char *argv[]) { register int i, j; int N, l, r; read (N); number[0].set (0); for (i = 1; i <= N; ++ i) { number[i].reset (); read (l); read (r); for (j = l; j <= r; ++ j) number[i] |= (number[i - 1] << (j * j)); } printf ("%d\n", number[N].count ()); return 0; }
LibreOJ #515. 「LibreOJ β Round #2」贪心只能过样例
标签:bsp names main bre void amp etc ber eset
原文地址:http://www.cnblogs.com/ZlycerQan/p/7309165.html