链接:https://ac.nowcoder.com/acm/contest/881/B

来源:牛客网

Integration

时间限制:C/C++ 2秒,其他语言4秒

空间限制:C/C++ 524288K,其他语言1048576K

64bit IO Format: %lld

题目描述

Bobo knows that





0

1

1

+

x

2

d

x

π

2

.

∫0∞11+x2 dx=π2.

Given n distinct positive integers

a

1

,

a

2

,



,

a

n

a1,a2,…,an, find the value of

1

π





0

1



n

i

1

(

a

2

i

+

x

2

)

d

x

.

1π∫0∞1∏i=1n(ai2+x2) dx.

It can be proved that the value is a rational number

p

q

pq.

Print the result as

(

p



q



1

)

mod

(

10

9

+

7

)

(p⋅q−1)mod(109+7).

输入描述:

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

a

1

,

a

2

,



,

a

n

a1,a2,…,an.

1



n



10

3

1≤n≤103

*

1



a

i



10

9

1≤ai≤109

*

{

a

1

,

a

2

,



,

a

n

}

{a1,a2,…,an} are distinct.

  • The sum of

    n

    2

    n2 does not exceed

    10

    7

输出描述:

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

示例1

输入

复制

1

1

1

2

2

1 2

输出

复制

500000004

250000002

83333334

题意:



思路:

事实上我并不会上面的处理,真正积分的话要用裂项相消来出来。

但是有强大的自动积分软件啊: https://www.wolframalpha.com/

输入一个n=5的 情况,就可以看出规律。

细节见代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) {ll ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
inline void getInt(int* p);
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll a[maxn];
int n;
const ll mod = 1e9 + 7;
int main() {
//freopen("D:\\code\\text\\input.txt","r",stdin);
//freopen("D:\\code\\text\\output.txt","w",stdout);
gbtb;
while (cin >> n) {
repd(i, 1, n) {
cin >> a[i];
}
ll ans = 0ll;
repd(i, 1, n) {
ll sum = 1ll;
repd(j, 1, n) {
if (i != j)
sum = sum * ((a[j] * a[j] - a[i] * a[i]) % mod) % mod;
}
// sum = (sum + mod) % mod;
sum = (sum * a[i]) % mod;
sum = (sum * 2ll) % mod;
sum = powmod(sum, mod - 2ll, mod);
ans = (ans + sum) % mod; }
ans = (ans + mod) % mod;
cout << ans << endl;
} return 0;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {
*p = *p * 10 - ch + '0';
}
} else {
*p = ch - '0';
while ((ch = getchar()) >= '0' && ch <= '9') {
*p = *p * 10 + ch - '0';
}
}
}

2019牛客暑期多校训练营(第一场) B Integration (数学)的更多相关文章

  1. 2019牛客暑期多校训练营(第二场) H-Second Large Rectangle(单调栈)

    题意:给出由01组成的矩阵,求求全是1的次大子矩阵. 思路: 单调栈 全是1的最大子矩阵的变形,不能直接把所有的面积存起来然后排序取第二大的,因为次大子矩阵可能在最大子矩阵里面,比如: 1 0 0 1 ...

  2. 2019牛客暑期多校训练营(第九场) D Knapsack Cryptosystem

    题目 题意: 给你n(最大36)个数,让你从这n个数里面找出来一些数,使这些数的和等于s(题目输入),用到的数输出1,没有用到的数输出0 例如:3  4 2 3 4 输出:0 0 1 题解: 认真想一 ...

  3. 2019牛客暑期多校训练营(第五场)G - subsequeue 1 (一题我真的不会的题)

    layout: post title: 2019牛客暑期多校训练营(第五场)G - subsequeue 1 (一题我真的不会的题) author: "luowentaoaa" c ...

  4. 2019牛客暑期多校训练营(第一场)A Equivalent Prefixes(单调栈/二分+分治)

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

  5. 2019牛客暑期多校训练营(第一场)A题【单调栈】(补题)

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

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

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

  7. 2019牛客暑期多校训练营(第二场)F.Partition problem

    链接:https://ac.nowcoder.com/acm/contest/882/F来源:牛客网 Given 2N people, you need to assign each of them ...

  8. 2019牛客暑期多校训练营(第九场)A:Power of Fibonacci(斐波拉契幂次和)

    题意:求Σfi^m%p. zoj上p是1e9+7,牛客是1e9:  对于这两个,分别有不同的做法. 前者利用公式,公式里面有sqrt(5),我们只需要二次剩余求即可.     后者mod=1e9,5才 ...

  9. 2019牛客暑期多校训练营(第八场)E.Explorer

    链接:https://ac.nowcoder.com/acm/contest/888/E来源:牛客网 Gromah and LZR have entered the fifth level. Unli ...

随机推荐

  1. Day1_Python基础一

    一.基本认识 1.计算机基础 CPU:计算 内存:缓存 硬盘:存储 操作系统:硬件与软件的桥梁 应用程序:应用的平台 2.Python的历史 1989年龟叔,追求清晰.简单.优美的原则. 主要领域:云 ...

  2. leetcode 72. 编辑距离

    /***** 定义状态: DP[i][j]其中i表示word1前i个字符,j表示Word2前i个字符 DP[i][j]表示单词1前i个字符匹配单词2前j个字符,最少变换次数: 状态转移: for i: ...

  3. python之注释的分类

    <1> 单行注释 以#开头,#右边的所有东西当做说明,而不是真正要执行的程序,起辅助说明作用 # 我是注释,可以在里写一些功能说明之类的哦 print('hello world') < ...

  4. 我非要捅穿这 Neutron(一)网络实现模型篇

    目录 文章目录 目录 前言 传统网络到虚拟化网络的演进 单一平面网络到混合平面网络的演进 Neutron 简述 Neutron 的网络实现模型 计算节点网络实现模型 内外 VID 转换 网络节点网络实 ...

  5. opencv的曲线拟合polyfit

    推荐一个不错的网页,可以直接用solve函数求解方程组: http://m.blog.csdn.net/u014652390/article/details/52789591 4.1 曲线拟合的最小二 ...

  6. ARM汇编指令特点

    根据朱有鹏老师课程笔记整理而来: (汇编)指令是CPU机器指令的助记符,经过编译后会得到一串1 0组成的机器码,由CPU读取执行. (汇编)伪指令本质上不是指令(只是和指令一起写在代码中),它是编译器 ...

  7. 关于java中设计原则总结(7)

    开闭原则: 对于类,模块函数等扩展要开放,对于修改要关闭. 依赖倒置: 接口或抽象是高层,要面向高层编程,不应该面向实现类(实现类是低层)去变成. 单一职责: 对一个类,或者一个功能,只用负责一个职责 ...

  8. 简述Vue中使用Vuex

    1.为什么要用vuex 在vue组件通信的过程中,我们通信的目的往往就是在组件之间传递数据或组件的状态(这里将数据和状态统称为状态),进而更改状态.但可以看到如果我们通过最基本的方式来进行通信,一旦需 ...

  9. tez

    参考: 原理: https://www.cnblogs.com/rongfengliang/p/6991020.html https://www.cnblogs.com/hankedang/p/421 ...

  10. [转帖]LSB

    LSB 简介 冯 锐2006 年 8 月 07 日发布 https://www.ibm.com/developerworks/cn/linux/l-lsb-intr/ 学习一下 之前 不知道LSB_R ...