#include <stdio.h>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define N 100100
using namespace std ;
typedef long long ll ;
struct node
{
ll x , y ;
};
node a[N] ;
ll n , m , k ;
ll num[N] ;
ll tot ;
int cmp(node a , node b)
{
if(a.x == b.x) return a.y < b.y ;
return a.x < b.x ;
}
ll quick_my(ll a , ll b)
{
ll ret = 1 ;
while(b)
{
if(b&1)ret=(ret*a)%mod;
a=(a*a)%mod;
b/=2;
}
return ret ;
}
int main()
{
scanf("%lld%lld%lld" , &n , &m , &k) ;
for(int i = 1 ; i <= k ; i++)
{
scanf("%lld%lld" , &a[i].x , &a[i].y) ;
}
sort(a+1 , a+k+1 , cmp) ;
for(int i = 1 ; i <= k ; i++)
{
if(a[i].x==a[i-1].x&&a[i].y==a[i-1].y) continue ;
if(a[i].x!=a[i-1].x)
{
tot ++ ;
num[tot] = (num[tot]+a[i].y)%mod ;
continue ;
}
if(a[i].x==a[i-1].x&&a[i].y!=a[i-1].y)
{
num[tot] = (num[tot]+a[i].y)%mod ;
continue ;
}
}
ll tmp = ((n*(n+1))/2)%mod ;
ll ans = quick_my(tmp,m-tot);
for(int i = 1 ; i <= tot ; i++)
{
ans = (ans*((((tmp-num[i])%mod)+mod)%mod))%mod ;
}
printf("%lld\n" , ans) ;
}
原文地址:http://blog.csdn.net/wzq_qwq/article/details/45625523