BZOJ5091 picking apples BZOJ2017 November month math derivation inverse element

Source: Internet
Author: User

Welcome to the original source-- Blog Park-zhouzhendong go to the blog Park to see the puzzle Topic Portal-BZOJ5091 November month bTest Instructions Summary

  

Solving

Code
#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 picking apples BZOJ2017 November month math derivation inverse element

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.