本文已参与「新人创作礼」活动,一起开启掘金创作之路。
题目链接:
解题思路:
编辑
编辑
AC代码:
#include<bits/stdc++.h>
#define up(i, x, y) for(ll i = x; i <= y; i++)
#define down(i, x, y) for(ll i = x; i >= y; i--)
#define bug prllf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define IO ios::sync_with_stdio(false),cin.tie(0)
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ll maxn = 1e5 + 7;
const double pi = acos(-1);
const ll inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
ll n, a[maxn];
ll power(ll a , ll b)
{
ll ans = 1;
while(b)
{
if(b & 1) ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}
int main()
{
while(~scanf("%lld", &n))
{
ll ans = 0;
for(ll i = 1; i <= n; i++)
{
scanf("%lld", &a[i]);
}
for(ll i = 1; i <= n; i++)
{
ll t = 2 * a[i] % mod;
for(ll j = 1; j <= n; j++)
{
if(i == j) continue;
t = (t * ((a[j] * a[j] % mod) - (a[i] * a[i] % mod) + mod) % mod) % mod;
}
ans = (ans + 1LL * power(t, mod - 2) ) % mod;
}
cout<<ans<<'\n';
}
}