1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| #include<bits/stdc++.h> using namespace std; void read(int &x) { x=0;int f=1;char ch=getchar(); for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f; for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f; } void print(int x) { if(x<0) putchar('-'),x=-x; if(!x) return ;print(x/10),putchar(x%10+48); } void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');} #define lf double #define ll long long #define pii pair<int,int > #define vec vector<int > #define pb push_back #define mp make_pair #define fr first #define sc second #define data asd09123jdf02i3h #define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++) const int maxn = 1e6+10; const int inf = 1e9; const lf eps = 1e-8; const int mod = 1e9+7; const int inv2 = 5e8+4; int n,a[maxn],b[maxn],g[4020][4020],fac[maxn],ifac[maxn],inv[maxn]; #define f(x,y) g[x+2003][y+2003] int c(int a,int b) {return 1ll*fac[a]*ifac[b]%mod*ifac[a-b]%mod;} void gen() { int N=2e4;fac[0]=ifac[0]=inv[0]=inv[1]=1; for(int i=1;i<N;i++) { fac[i]=1ll*fac[i-1]*i%mod; if(i>1) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod; ifac[i]=1ll*ifac[i-1]*inv[i]%mod; } } int main() { read(n);gen(); for(int i=1;i<=n;i++) read(a[i]),read(b[i]),f(-a[i],-b[i])++; for(int i=-2000;i<=2000;i++) for(int j=-2000;j<=2000;j++) f(i,j)=((f(i,j)+f(i-1,j))%mod+f(i,j-1))%mod; int ans=0; for(int i=1;i<=n;i++) ans=(ans+f(a[i],b[i]))%mod; for(int i=1;i<=n;i++) ans=(ans-c(2*(a[i]+b[i]),a[i]*2)+mod)%mod; write(1ll*ans*inv2%mod); return 0; }
|