2019年牛客多校第一場 B題 Integration 數學

題目連接

傳送門ios

題目

思路

首先咱們對\(\int_{0}^{\infty}\frac{1}{\prod\limits_{i=1}^{n}(a_i^2+x^2)}dx\)進行裂項相消:
\[ \begin{aligned} &\frac{1}{\prod\limits_{i=1}^{n}(a_i^2+x^2)}&\\ =&\frac{1}{(a_1^2+x^2)(a_2^2+x^2)}\times\frac{1}{\prod\limits_{i=3}^{n}(a_i^2+x^2)}&\\ =&\frac{1}{a_2^2-a_1^2}\times(\frac{1}{a_1^2+x^2}-\frac{1}{a_2^2+x^2})\times\frac{1}{\prod\limits_{i=3}^{n}(a_i^2+x^2)}&\\ =&\frac{1}{a_2^2-a_1^2}\times(\frac{1}{a_1^2+x^2}\times\frac{1}{a_3^2+x^2}-\frac{1}{a_2^2+x^2}\times\frac{1}{a_3^2+x^2})\times\frac{1}{\prod\limits_{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}{\prod\limits_{j=1,j\not=i}^{n}(a_j^2-a_i^2)}\),所以最後題目要求的式子久變成了下式:
\[ \begin{aligned} &\sum\limits_{i=1}^{n}\frac{1}{\prod\limits_{j=1,j\not=i}^{n}(a_j^2-a_i^2)}\int_0^{\infty}\frac{1}{a_i^2+x^2}dx&\\ =&\sum\limits_{i=1}^{n}\frac{1}{\prod\limits_{j=1,j\not=i}^{n}(a_j^2-a_i^2)\times a_i^2}\int_0^{\infty}\frac{1}{1+(\frac{x}{a_i})^2}dx&\\ =&\sum\limits_{i=1}^{n}\frac{1}{\prod\limits_{j=1,j\not=i}^{n}(a_j^2-a_i^2)\times a_i}\int_0^{\infty}\frac{1}{1+(\frac{x}{a_i})^2}d\frac{x}{a_i}& \end{aligned} \]
積分符號裏面的東西就是題目給的式子獲得\(\frac{\pi}{2}\),所以最後答案爲
\[ \begin{aligned} &\sum\limits_{i=1}^{n}\frac{1}{2\times\prod\limits_{j=1,j\not=i}^{n}(a_j^2-a_i^2)\times a_i} \end{aligned} \]spa

代碼實現以下

#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("*********\n")
#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\n", ans);
    }
    return 0;
}
相關文章
相關標籤/搜索