題目:簡單瞎搞題
題解:這題用bitset+dp優化。
dp[i],表示在第i段的時候,此時要多少個滿足題目的解。
/*
┏┓ ┏┓
*┏┛┻━━━┛┻┓
*┃ ┃
*┃ ━ ┃
*┃ ┳┛ ┗┳ ┃
*┃ ┃
*┃ ┻ ┃
*┃ ┃
*┗━┓ ┏━┛
* ┃ ┃神獸保佑
* ┃ ┃代碼無BUG!
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
*
*/
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int N = 1e5+10;
const ll mod = 1e9+7;
const ll inf = 10000000000000000;
int random(int n){return (ll)rand()*rand()%n;}
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch =getchar();}
while('0'<=ch&&ch<='9'){x=x*10+ch-'0';ch=getchar();
}return x*f;
}
ll fast_pow(ll a,ll p){
ll ans = 1;
while(p){
if(p&1) ans = (ans*a)%mod;
p >>= 1;
a = (a*a)%mod;
}
return ans;
}
bitset<1000005>dp[105];
int main(){
//srand((unsigned)time(0));
//freopen("out.txt","w",stdout);
dp[0][0] = 1;
int n = read();
for(int i = 1;i <= n;i++){
int l = read(),r = read();
for(int j = l;j <= r;j++){
dp[i] |= dp[i-1]<<(j*j);//表示上一個的所以情況在這裏都同時的左移,所以就把重複的都取消了
}
}
cout<<dp[n].count()<<endl;
return 0;
}