牛客多校第一场 B Inergratiion

传送门:https://ac.nowcoder.com/acm/contest/881/B

题意:

给你一个 [求值为多少

题解:

根据线代的知识

我们可以将分母裂项,然后根据

\(\int_{0}^{\infty} \frac{1}{1+x^2}dx=\frac{\pi}{2}-->\int_{0}^{\infty} \frac{1}{1+\frac{x}{a_i}^2}d\frac{x}{a_i}=\frac{\pi}{2}\)

可以推得

我们的答案就是裂项后求出来的系数乘上\(\frac{\pi}{2}\)

详情请看D神推导吧

https://www.cnblogs.com/Dillonh/p/11209476.html#4304562

代码:

#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef unsigned long long uLL;
#define ls rt<<1
#define rs rt<<1|1
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define bug printf("*********\n")
#define FIN freopen("input.txt","r",stdin);
#define FON freopen("output.txt","w+",stdout);
#define IO ios::sync_with_stdio(false),cin.tie(0)
#define debug1(x) cout<<"["<<#x<<" "<<(x)<<"]\n"
#define debug2(x,y) cout<<"["<<#x<<" "<<(x)<<" "<<#y<<" "<<(y)<<"]\n"
#define debug3(x,y,z) cout<<"["<<#x<<" "<<(x)<<" "<<#y<<" "<<(y)<<" "<<#z<<" "<<z<<"]\n"
const int maxn = 3e5 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
LL quick_pow(LL x, LL y) {
LL ans = 1;
while(y) {
if(y & 1) {
ans = ans * x % mod;
} x = x * x % mod;
y >>= 1;
} return ans;
}
LL a[maxn];
int main() {
#ifndef ONLINE_JUDGE
FIN
#endif
int n;
while(scanf("%d", &n) != EOF) {
for(int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
LL ans = 0;
for(int i = 0; i < n; i++) {
LL tmp = 1;
for(int j = 0; j < n; j++) {
if(i == j) continue;
tmp = (tmp * (quick_pow(a[j], 2) % mod - quick_pow(a[i], 2) % mod + mod) % mod) % mod;
}
tmp = tmp * 2 % mod * a[i] % mod;
ans = (ans + quick_pow(tmp, mod - 2) + mod) % mod;
}
printf("%lld\n", (ans + mod) % mod);
}
return 0;
}

牛客多校第一场 B Inergratiion的更多相关文章

  1. 2019牛客多校第一场 I Points Division(动态规划+线段树)

    2019牛客多校第一场 I Points Division(动态规划+线段树) 传送门:https://ac.nowcoder.com/acm/contest/881/I 题意: 给你n个点,每个点有 ...

  2. 2019年牛客多校第一场B题Integration 数学

    2019年牛客多校第一场B题 Integration 题意 给出一个公式,求值 思路 明显的化简公式题,公式是分母连乘形式,这个时候要想到拆分,那如何拆分母呢,自然是裂项,此时有很多项裂项,我们不妨从 ...

  3. 2019牛客多校第一场E ABBA(DP)题解

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

  4. 牛客多校第一场 A Equivalent Prefixes 单调栈(笛卡尔树)

    Equivalent Prefixes 单调栈(笛卡尔树) 题意: 给出两个数组u,v,每个数组都有n个不同的元素,RMQ(u,l,r)表示u数组中[l,r]区间里面的最小值标号是多少,求一个最大的m ...

  5. 2019牛客多校第一场A-Equivalent Prefixes

    Equivalent Prefixes 传送门 解题思路 先用单调栈求出两个序列中每一个数左边第一个小于自己的数的下标, 存入a[], b[].然后按照1~n的顺序循环,比较 a[i]和b[i]是否相 ...

  6. 2019年牛客多校第一场 I题Points Division 线段树+DP

    题目链接 传送门 题意 给你\(n\)个点,每个点的坐标为\((x_i,y_i)\),有两个权值\(a_i,b_i\). 现在要你将它分成\(\mathbb{A},\mathbb{B}\)两部分,使得 ...

  7. 2019年牛客多校第一场 H题XOR 线性基

    题目链接 传送门 题意 求\(n\)个数中子集内所有数异或为\(0\)的子集大小之和. 思路 对于子集大小我们不好维护,因此我们可以转换思路变成求每个数的贡献. 首先我们将所有数的线性基的基底\(b\ ...

  8. 2019牛客多校第一场 A.Equivalent Prefixes

    题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r ...

  9. 2019 牛客多校第一场 D Parity of Tuples

    题目链接:https://ac.nowcoder.com/acm/contest/881/D 看此博客之前请先参阅吕凯飞的论文<集合幂级数的性质与应用及其快速算法>,论文中很多符号会被本文 ...

随机推荐

  1. 【C++】去除vector里重复元素的方法比较

    背景:构造一个无重复的白名单,之后要在里面进行二分查找.故要求名单有序,且无重复,并且要进行二分查找,所以要采用有:随机访问迭代器类型的容器.这类容器有vector,array,deque.显然要ve ...

  2. LeetCode107 Binary Tree Level Order Traversal II

    Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left ...

  3. javascript中字符的一些常规操作

    1,获取第一个字符 var str = "hello word"; console.log(str[0]); // h 2,获取最后一个字符 var str = "hel ...

  4. onethink 返回上一页

    // 记录当前列表页的cookie        Cookie('__forward__',$_SERVER['REQUEST_URI']); $this->success('操作成功!',Co ...

  5. AUTO uninstaller 密钥/激活码/破解/注册机 ver 8.9.05 资源下载【转载】

    技术贴:AUTO uninstaller 密钥/激活码/破解/注册机 ver 8.9.05 资源下载 楼主分享几个auto uninstaller密钥破解注册机,可以用于AUTO uninstalle ...

  6. mysql原来是按自然日统计。怎么可以用今天10点到次日10点这样统计???

    关于网友提出的" mysql原来是按自然日统计.怎么可以用今天10点到次日10点这样统计???"问题疑问,本网通过在网上对" mysql原来是按自然日统计.怎么可以用今天 ...

  7. 2018-8-10-Roslyn-节点的-Span-和--FullSpan-有什么区别

    title author date CreateTime categories Roslyn 节点的 Span 和 FullSpan 有什么区别 lindexi 2018-08-10 19:16:52 ...

  8. 模板—LCT

    #include<iostream> #include<cstring> #include<cstdio> #define LL long long using n ...

  9. hihocoder1994 树与落叶 DFS+前缀和+二分

    DFS找到节点删除的时间,删除的时间其实就是子树的最长链,然后给每个点打一个时间戳,然后求每个时间点对应删除的节点的个数,对于1-max_time时间戳求一个前缀和,然后二分找到和m距离最近的那一天 ...

  10. HDU-6703-array-2019CCPC选拔赛

    我TM真是一个弟弟... 题意: 给出一串1-N的数字 你每次可以把某个位置的值+1000000 或者找一个值,所有a[1]...a[r]序列的数都不能等于这个值,并且这个值>w 当时比赛觉得肯 ...