牛客多校第一场 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;
}