[牛客练习赛22] C-简单瞎搞题

题目

题目描述
一共有 n个数,第 i 个数是 xi
xi 可以取 [li , ri] 中任意的一个值。
设 ,求 S=xi^2(求和) 种类数。
输入描述:
第一行一个数 n。
然后 n 行,每行两个数表示 li,ri。

输出描述:
输出一行一个数表示答案。

示例1
输入
5
1 2
2 3
3 4
4 5
5 6
输出
26

备注:
1 ≤ n , li , ri ≤ 100


解题思路
//代码片段
//zhicheng
#include
const int Max=1e6+5;
using namespace std;
bitset  ans,temp;

int main(){
    int n,l,r;

    while(scanf("%d",&n)!=EOF){

        ans[0]=1;
        while(n--){
            scanf("%d%d",&l,&r);
            temp.reset();
            for(;l<=r;l++)
                temp|=ans<<(l*l);
            ans=temp;
        }

        printf("%d\n",ans.count());
    }

    return 0;
}

铺子日常更新,如有错误请指正
传送门: 题目链接

你可能感兴趣的:([算法编程]牛客小练)