题目描述
给定两个下标从 1 到 n 编号的序列 ai,bi,定义函数 S(l,r)(1≤l≤r≤n) 为:
i=l∑rai×i=l∑rbi
请你求出下列式子的值:
S(l,r)l=1∑nr=l∑nS(l,r)
由于答案可能很大,你只需要给出答案模 10^9+7109+7 后的结果。
输入格式
第一行一个正整数 n 表示序列长度。
第二行 n 个正整数表示 ai。
第三行 n 个正整数表示bi。
输出格式
仅一行一个整数表示答案模 10^9+7 后的结果。
输入输出样例
输入 #1复制
3 2 3 4 3 4 5
输出 #1复制
244
输入 #2复制
5 11 22 33 44 55 12 34 56 78 90
输出 #2复制
201542
题解:
题解随后会公布
AC code:
#include<cstdio>
#define mod 1000000007
long long ai[500003];
long long bi[500003];
long long prea[500003];
long long preb[500003];
long long ans=0,temp1=0,temp2=0;
int main(){
int tot;
scanf("%d",&tot);
for(int i=1;