One of the pits, using lucas to generate the number of combinations is always wrong. Later, I saw that others used the inverse element to generate it, so I used the inverse element, and found that the inverse element is really amazingly fast. I still didn't think about the complexity seriously. When I saw lucas, I wanted to set the template, and I didn't think about the complexity at all.
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+7; int mod = 1e9+7; typedef unsigned long long LL; LL jie[110000]; void init() { jie[0]=jie[1]=1; for(int i=2; i<=100000; i++) they [i] = (they [i-1] * i)% mod; } LL mult(LL a,LL n) { LL ans=1; while(n) { if(n&1)ans=(ans*a)%mod; a=(a*a)%mod; n>>=1; } return ans; } LL C(LL n,LL m) { return (jie [n] * mult (jie [nm], mod-2))% mod * mult (jie [m], mod-2))% mod; } int x,val; intmain() { init(); int n,t,w; while(~scanf("%d%d%d",&n,&t,&w)) { LL ans=0; for(int i=1;i<=n;i++) { scanf("%d%d",&x,&val); x-=t; if(w<x)continue; int tmp=w-x; if(tmp%2)continue; tmp/=2; if(tmp>t)continue; //cout<<tmp<<endl; if(tmp*2>t) tmp=t-tmp; ans+=C(t,tmp)*val; ans% = mod; } printf("%lld\n",ans); } return 0; }