标签:访问 cstring amp images zoj str cpp const .com


#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=100005;
const LL mod=1000000007;
LL LLPow(LL x,LL y){
if (y==0)
return 1LL;
LL xx=LLPow(x,y/2);
xx=xx*xx%mod;
if (y&1LL)
xx=xx*x%mod;
return xx;
}
LL Inv(LL x){
return LLPow(x,mod-2);
}
LL n,m,k,d[N],a[N];
int main(){
memset(d,0,sizeof d);
scanf("%d%d%d",&n,&m,&k);
for (int i=1;i<=n;i++)
scanf("%d",&a[i]);
for (int i=1,a,b;i<=m;i++){
scanf("%d%d",&a,&b);
d[a]++,d[b]++;
}
LL ans=0;
for (int i=1;i<=n;i++)
ans=(ans+d[i]*a[i])%mod;
printf("%lld",ans*Inv(m*2)%mod*k%mod);
return 0;
}
BZOJ5091 摘苹果 BZOJ2017年11月月赛 数学推导 逆元
标签:访问 cstring amp images zoj str cpp const .com
原文地址:http://www.cnblogs.com/zhouzhendong/p/8012643.html