天天看點

LOJ #515. 「LibreOJ β Round #2」貪心隻能過樣例

#include <bits/stdc++.h>

using namespace std;
int n, a, b;
bitset<1000010> st[110];

int main(int argc, char const *argv[]) {
  cin >> n; st[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a, &b);
    for (int j = a; j <= b; j++)
      st[i] |= st[i - 1] << (j * j);
  }
  cout << st[n].count() << endl;
}      

繼續閱讀