站外求助qwq

题目总版

沐咕 @ 2024-11-22 20:50:02

暴力过不了qwq


by LG_jyc @ 2024-11-22 20:56:45

对于第i个数,显然发现有i \times (n-i+1)个区间会包容它,直接O(n)扫一遍即可。


by ycyxh1 @ 2024-11-22 20:59:26

@沐咕


by ycyxh1 @ 2024-11-22 21:01:07

#include<bits/stdc++.h>
#define md 1000000007
using namespace std;
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    long long ans=0;
    for(int i=1;i<=n;i++){
        int w;
        cin>>w;
        ans+=(__int128)w*(n-i+1)*i%md;
        ans%=md;
    }
    cout<<ans;
    return 0;
}

by 沐咕 @ 2024-11-22 21:15:49

@ycyxh1@LG_jycthx


by LG_jyc @ 2024-11-22 21:17:09

@沐咕

求互关


|