信息学奥赛一本通高手训练1680:序列

本文主要探讨了信息学奥赛中关于序列的难题,通过实例解析和C语言代码展示,帮助参赛者提升解题技巧,适合蓝桥杯等竞赛训练。
摘要由CSDN通过智能技术生成

题目

代码

#include<cstdio>
#include<iostream>
#include<cmath>
#define LL long long
using namespace std;
const LL N = 1400000+7;
const LL mod = 1e9+7;
int n, t;
LL pos[N], sum[N], ans[N];
struct node{
    LL ll, rr;
}a[N];
int main(){
    pos[1] = 1, pos[2] = 3; int cnt = 2; LL temp = 2;
    a[1].ll = a[1].rr = 1;
    a[2].ll = 2; a[2].rr = 3;
    for(int i=3; i<=N; i++){
        pos[i] = pos[i-1] + cnt;
        a[i].rr = pos[i];
        a[i].ll = pos[i-1] + 1;
        if(i >= pos[temp]){
            cnt++; temp++;
        }
    }
    for(int i=1; i<=N; i++){
        sum[i] = sum[i-1] + (a[i].rr-a[i].ll+1) * i * (a[i].ll+a[i].rr) / 2 % mod;
        sum[i] %= mod;
    }
    scanf("%d&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值