zoukankan      html  css  js  c++  java

传送门

# 思路

首先我们对(int_{0}^{infty}frac{1}{prodlimits_{i=1}^{n}(a_i^2+x^2)}dx)进行裂项相消：

[egin{aligned} &frac{1}{prodlimits_{i=1}^{n}(a_i^2+x^2)}&\ =&frac{1}{(a_1^2+x^2)(a_2^2+x^2)} imesfrac{1}{prodlimits_{i=3}^{n}(a_i^2+x^2)}&\ =&frac{1}{a_2^2-a_1^2} imes(frac{1}{a_1^2+x^2}-frac{1}{a_2^2+x^2}) imesfrac{1}{prodlimits_{i=3}^{n}(a_i^2+x^2)}&\ =&frac{1}{a_2^2-a_1^2} imes(frac{1}{a_1^2+x^2} imesfrac{1}{a_3^2+x^2}-frac{1}{a_2^2+x^2} imesfrac{1}{a_3^2+x^2}) imesfrac{1}{prodlimits_{i=4}^{n}(a_i^2+x^2)}&\ =&dots& end{aligned} ]

依次裂项相消，然后看系数的规律，可以手动推(n=2,3)的系数看规律，也可以计算，比赛的时候我(n=3)推到一半队友看到式子和我说这个他学过然后把系数告诉我就(A)了(队友(txdy))。
每个(frac{1}{a_i^2+x^2})的系数为(frac{1}{prodlimits_{j=1,j ot=i}^{n}(a_j^2-a_i^2)})，因此最后题目要求的式子久变成了下式：

[egin{aligned} &sumlimits_{i=1}^{n}frac{1}{prodlimits_{j=1,j ot=i}^{n}(a_j^2-a_i^2)}int_0^{infty}frac{1}{a_i^2+x^2}dx&\ =&sumlimits_{i=1}^{n}frac{1}{prodlimits_{j=1,j ot=i}^{n}(a_j^2-a_i^2) imes a_i^2}int_0^{infty}frac{1}{1+(frac{x}{a_i})^2}dx&\ =&sumlimits_{i=1}^{n}frac{1}{prodlimits_{j=1,j ot=i}^{n}(a_j^2-a_i^2) imes a_i}int_0^{infty}frac{1}{1+(frac{x}{a_i})^2}dfrac{x}{a_i}& end{aligned} ]

积分符号里面的东西就是题目给的式子得到(frac{pi}{2})，因此最后答案为

[egin{aligned} &sumlimits_{i=1}^{n}frac{1}{2 imesprodlimits_{j=1,j ot=i}^{n}(a_j^2-a_i^2) imes a_i} end{aligned} ]

# 代码实现如下

``````#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;

typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pLi;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

#define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********
")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://Code//in.txt","r",stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0)

const double eps = 1e-8;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
const double pi = acos(-1);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;

int n;
int a[maxn], inv[maxn], cnt[maxn];

LL qpow(LL x, int n) {
LL res = 1;
while(n) {
if(n & 1) res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}

int main() {
int tmp = qpow(2, mod - 2);
while(~scanf("%d", &n)) {
for(int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
}
for(int i = 1; i <= n; ++i) {
cnt[i] = 1;
for(int j = 1; j <= n; ++j) {
if(i == j) continue;
cnt[i] = 1LL * cnt[i] * ((1LL * a[j] * a[j] % mod - 1LL * a[i]* a[i] % mod) % mod + mod) % mod;
}
cnt[i] = qpow(cnt[i], mod - 2);
cnt[i] = 1LL * cnt[i] * qpow(a[i], mod - 2) % mod;
cnt[i] = 1LL * cnt[i] * tmp % mod;
}
LL ans = 0;
for(int i = 1; i <= n; ++i) {
ans = ((ans + cnt[i]) % mod + mod) % mod;
}
printf("%lld
", ans);
}
return 0;
}

``````
• 相关阅读:
设置圆形头型并且可以点击
不可忽略的知识点
【Java基础】03_Java常用API
常用键盘功能键和快捷键以及DOS命令
【Excel 2013 数据透视表 学习】一、创建数据透视表
【Java基础】05_异常&File
【Java基础】04_集合框架
【设计模式之禅】第2章 里氏替换原则
【设计模式之禅】第1章 单一职责原则
Eclipse中快捷键的使用
• 原文地址：https://www.cnblogs.com/Dillonh/p/11209476.html