链接:https://ac.nowcoder.com/acm/contest/881/B
来源:牛客网

Bobo knows that 

Given n distinct positive integers a1,a2,…,anfind the value of

It can be proved that the value is a rational number
Print the result as 

输入描述:

The input consists of several test cases and is terminated by end-of-file.The first line of each test case contains an integer n.
The second line contains n integers a1,a2,…,an* 1≤n≤1e3
* 1≤ai≤1e9
* {a1,a2,…,an} are distinct.
* The sum of n*n does not exceed 1e7.

输出描述:

For each test case, print an integer which denotes the result.

示例1

输入

复制

1
1
1
2
2
1 2

输出

复制

500000004
250000002
83333334

思路,裂项相消+积分公式

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#include<list>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
ll a[1005];
int n;
ll ksm(ll a,ll b){ll s=1;while(b){if(b&1)s = s * a % mod;a= a *a %mod;b>>=1;}return s%mod;
}
int main(){while(~scanf("%d",&n)){for(int i=1;i<=n;i++){scanf("%d",&a[i]);}ll ans=0;for(int i=1;i<=n;i++){ll temp=1;for(int j=1;j<=n;j++){if(j!=i){temp*=(a[j]*a[j]-a[i]*a[i])%mod;temp=(temp%mod+mod)%mod;}}ans+=ksm(temp*(a[i]<<1)%mod,mod-2)%mod;ans%=mod; } printf("%lld\n",ans);}return 0;
} 

2019牛客暑期多校训练营(第一场) Integration(定积分)相关推荐

  1. 2019牛客暑期多校训练营(第一场场)_I题Points Division(线段树+DP维护区间最大值)

    题目链接: https://ac.nowcoder.com/acm/contest/881/I 题意: 给你n个点,每个点的坐标为(xi,yi),有两个权值ai,bi. 现在要你将它分成A,B两部分, ...

  2. 2019牛客暑期多校训练营(第三场)H.Magic Line

    2019牛客暑期多校训练营(第三场)H.Magic Line 题目链接 题目描述 There are always some problems that seem simple but is diff ...

  3. 2019牛客暑期多校训练营(第五场)C generator 2 (BSGS)

    2019牛客暑期多校训练营(第五场)C generator 2 思路 x0=x0x_0 = x_0x0​=x0​ x1=a∗x0∗bx_1 = a * x_0 * bx1​=a∗x0​∗b x2=a∗ ...

  4. 2019牛客暑期多校训练营(第四场)----E- triples II

    首先发出题目链接: 链接:https://ac.nowcoder.com/acm/contest/884/E 来源:牛客网 涉及:位运算,容斥定义,dp 点击这里回到2019牛客暑期多校训练营解题-目 ...

  5. 2019牛客暑期多校训练营(第一场)

    传送门 参考资料: [1]:官方题解(提取码:t050 ) [2]:标程(提取码:rvxr ) [3]:牛客题解汇总 A.Equivalent Prefixes(单调栈) •题意 定义两个数组 u,v ...

  6. 【2019牛客暑期多校训练营(第一场) - A】Equivalent Prefixes(单调栈,tricks)

    题干: 链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Two arrays u and v each with m distinct elem ...

  7. 2019牛客暑期多校训练营(第一场)E-ABBA(dp)

    链接:https://ac.nowcoder.com/acm/contest/881/E 来源:牛客网 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/C++ 524288K,其他语言1048 ...

  8. 2019牛客暑期多校训练营(第一场) A Equivalent Prefixes ( st 表 + 二分+分治)

    链接:https://ac.nowcoder.com/acm/contest/881/A 来源:牛客网 Equivalent Prefixes 时间限制:C/C++ 2秒,其他语言4秒 空间限制:C/ ...

  9. 【2019牛客暑期多校训练营(第一场) - H】XOR(线性基,期望的线性性)

    题干: 链接:https://ac.nowcoder.com/acm/contest/881/H 来源:牛客网 Bobo has a set A of n integers a1,a2,-,ana1, ...

最新文章

  1. java final类 能被继承吗_Java中的类被final关键字修饰后,该类将不可以被继承()...
  2. 分布式数据库切分规则介绍
  3. 源码调试debug_info 的作用和使用方法
  4. Flex里Application和TitleWindow数据交互方法
  5. DownloadManager不好用?试试ZlsamDownloadService
  6. php里的header,PHP中常用的header头部定义有哪些
  7. shell实现https登录
  8. 滑动轨迹 曲线 python_python曲线图
  9. 第十三章——表和索引分区(2)——使用拆分删除和加载大数据
  10. 基于 SurfaceView 的直播点亮心形效果
  11. CS224N刷题——Assignment2.3_RNN:Language Modeling
  12. 神经网络加速器设计研究:GoSPA ISCA2021论文研读
  13. Java:计算立方体的体积和底面积
  14. 在Windows 10 64 位机器上安装Debug
  15. 360自动收录js代码如何添加
  16. android谷歌服务框架(GoogleServicesFramework)
  17. 012:tkinter+爬虫设计对联软件
  18. 华为 dis ip routing-table怎么看?
  19. 【数据结构】赫夫曼树与编码
  20. 一体化运维平台规划介绍

热门文章

  1. Centos7 JDK安装过程中 解决java -version 报错: bash: /home/jdk1.8.0_161/bin/java: Permission denied...
  2. 《论语》全译——颜渊篇第十二
  3. Parrot linux 开机启动提示[TOMOYO] Problem starting the computer更新完重启开机的时候出现的这个提示。...
  4. 未来战场主宰者 人工智能改变战争【楚才国科】
  5. CTF中比较好玩的stego
  6. 汇川服务器型号,汇川技术电梯物联网解决方案
  7. 谈谈Persistent属性
  8. 迟绑定早绑定,迟早都要绑定
  9. mkvtool-cmd批处理之视频混流辅助工具
  10. tqdm介绍及常用方法