• 牛客多校第一场 B Inergratiion


    牛客多校第一场 B Inergratiion

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

    题意:

    给你一个 [img求值为多少

    题解:

    根据线代的知识

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

    (int_{0}^{infty} frac{1}{1+x^2}dx=frac{pi}{2}-->int_{0}^{infty} frac{1}{1+frac{x}{a_i}^2}dfrac{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("*********
    ")
    #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)<<"]
    "
    #define debug2(x,y) cout<<"["<<#x<<" "<<(x)<<" "<<#y<<" "<<(y)<<"]
    "
    #define debug3(x,y,z) cout<<"["<<#x<<" "<<(x)<<" "<<#y<<" "<<(y)<<" "<<#z<<" "<<z<<"]
    "
    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
    ", (ans + mod) % mod);
        }
        return 0;
    }
    
    每一个不曾刷题的日子 都是对生命的辜负 从弱小到强大,需要一段时间的沉淀,就是现在了 ~buerdepepeqi
  • 相关阅读:
    打造一个有感觉的vim(四)
    Sql Server中不常用的表运算符之UNPIVOT
    Sql Server中不常用的表运算符之PIVOT
    Sql Server中不常用的表运算符之APPLY(2)
    Sql Server中不常用的表运算符之APPLY(1)
    Sql Server隔离级别(2)
    Sql Server隔离级别(1)
    修改maven仓库位置
    Cannot change version of project facet Dynamic web的解决方法
    为 HTML 添加新元素
  • 原文地址:https://www.cnblogs.com/buerdepepeqi/p/11229438.html
Copyright © 2020-2023  润新知