积分
数字太多不好计算,可以先看看比较简单的几种情况:
n = 1时,可以直接积分出来,答案是 1/2a
n = 2时,我们把原式展开,拆成两个分数相加的形式,用待定系数法解出分子,然后发现可以转化成两个n=1的情况相加
n = 3时,还是和上面一样的方法,死算。
最后发现通式为:
\(\sum_{i=1}^n\frac{1}{2*a_i}\prod_{i=1}^n\frac{1}{a_j^2-a_i^2}\)
然后O(n^2)算就好了
#include#define INF 0x3f3f3f3f#define full(a, b) memset(a, b, sizeof a)#define FAST_IO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)using namespace std;typedef long long ll;inline int lowbit(int x){ return x & (-x); }inline int read(){ int ret = 0, w = 0; char ch = 0; while(!isdigit(ch)) { w |= ch == '-'; ch = getchar(); } while(isdigit(ch)) ret = (ret << 3) + (ret << 1) + (ch ^ 48), ch = getchar(); return w ? -ret : ret;}inline int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }inline int lcm(int a, int b){ return a / gcd(a, b) * b; }template inline T max(T x, T y, T z){ return max(max(x, y), z); }template inline T min(T x, T y, T z){ return min(min(x, y), z); }template inline A fpow(A x, B p, C lyd){ A ans = 1; for(; p; p >>= 1, x = 1LL * x * x % lyd)if(p & 1)ans = 1LL * x * ans % lyd; return ans;}const int N = 2000;const int MOD = 1e9 + 7;int n;ll a[N];int main(){ while(~scanf("%d", &n)){ for(int i = 1; i <= n; i ++) scanf("%lld", &a[i]); ll ans = 0; for(int i = 1; i <= n; i ++){ ll t = 2 * a[i] % MOD; for(int j = 1; j <= n; j ++){ if(i == j) continue; t = t % MOD * ((a[j] * a[j] % MOD + MOD - a[i] * a[i] % MOD) % MOD) % MOD; } ans = (ans % MOD + fpow(t, MOD - 2, MOD)) % MOD; } printf("%lld\n", ans); } return 0;}