#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<stack>
#include<map>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=1e5+5;
ll fact[maxn],f[maxn],inv[maxn];
void init()
{
fact[0]=f[0]=inv[1]=inv[0]=1;
for(int i=2;i<maxn;++i)
inv[i]=inv[mod%i]*(mod-mod/i)%mod;
for(int i=1;i<maxn;++i)
{
fact[i]=fact[i-1]*i%mod;
f[i]=f[i-1]*inv[i]%mod;
}
}
ll solve(ll n,ll m)
{
return fact[n]*f[m]%mod*f[n-m]%mod;
}
ll n,t,w;
ll abss(ll a)
{
return a>0?a:-a;
}
inline int read()
{
int k=0;
char f=1;
char c=getchar();
for(;!isdigit(c);c=getchar() )
if(c=='-')
f=-1;
for(;isdigit(c);c=getchar() )
k=k*10+c-'0';
return k*f;
}
int main()
{
init();
ll res,dis;int aa,bb;
while(scanf("%lld%lld%lld",&n,&t,&w)!=EOF)
{
res=0;
for(int i=0;i<n;++i)
{
aa=read();
bb=read();
dis=abss(aa-w);
if(dis>t||(dis+t)&1)
continue;
else
res=(res+bb*solve(t,(dis+t)/2))%mod;
}
printf("%lld\n",res);
}
return 0;
}
山东省第八届acm省赛C题 巨坑
最新推荐文章于 2018-05-03 15:48:43 发布