代码
#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&#