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


    题目链接

    传送门

    题目

    思路

    首先我们对(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;
    }
    
    
  • 相关阅读:
    MySql创建库 Challenge
    未能启用约束。一行或多行中包含违反非空、唯一或外键约束的值的解决办法.
    小总结:用反射机制创建的分配数据分配器
    工厂模式的反思
    单机安装“完整”SharePoint 2010
    作业调度框架 Quartz.NET 2.0 StepByStep(2)
    UI线程同步
    每日见闻(一)
    作业调度框架 Quartz.NET 2.0 StepByStep
    基础算法(ACwing)
  • 原文地址:https://www.cnblogs.com/Dillonh/p/11209476.html
Copyright © 2020-2023  润新知