BZOJ2751 [HAOI2012] Easy title

Source: Internet
Author: User

Easy for your whole family ...

As long as the sum of each number can be used, then the product can be

Use a map to do sth. Do a half day = =

1 /**************************************************************2 problem:27513 User:rausen4 language:c++5 result:accepted6 time:452 Ms7 memory:5828 KB8 ****************************************************************/9  Ten#include <cstdio> One#include <map> A    - using namespacestd; -typedefLong Longll; thetypedef pair <int,int>P; -typedef Map <int, ll>:: iterator IT; - Constll mod =1000000007; - intN, M, K, X, Y; + ll Sum, ans, del; -Map <p,BOOL>GOT; +Map <int, ll>A; A    at inline ll read () { -ll x =0; -     CharCH =GetChar (); -      while(Ch <'0'|| CH >'9') -CH =GetChar (); -    in      while(Ch >='0'&& CH <='9'){ -x = x *Ten+ CH-'0'; toCH =GetChar (); +     } -     returnx; the } *    $ll Pow (ll X,inty) {Panax Notoginsengll res =1; -      while(y) { the         if(Y &1) Res *= x, res%=MoD; +x *= x, x%=MoD; AY >>=1; the     } +     returnRes; - } $    $ intMain () { -n = Read (), M = Read (), k =read (); - P PR; the      while(k--){ -X = Read (), Y =read ();WuyiPR =Make_pair (X, Y); the         if(!GOT[PR]) -GOT[PR] =1, a[x] + =Y; Wu     } -Sum = (LL) n * (n +1) /2%MoD; AboutAns =1; $      for(IT i = A.begin (); I! = A.end (); + +i) { -del = Sum-isecond; -         if(Del <0) del + = (LL) ((-del/mod) +1) *MoD; -Ans *= del, ans%=MoD; A     } +printf"%lld\n", ans * POW (Sum, m-a.size ())%MoD); the     return 0; -}
View Code

BZOJ2751 [HAOI2012] Easy title

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.