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