代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#define int long long
using namespace std;
const int N=3000,M=998244353;
int n,k,x[N],y[N],a[N*N],inv[N*N],b[N*N];
void init()
{
scanf("%lld %lld",&n,&k);
for (int i=1;i<=n;i++)
scanf("%lld %lld",&x[i],&y[i]);
}
int ksm(int a,int b)
{
int res=1;
while(b)
{
if(b&1)
res=1ll*res*a%M;
b>>=1,a=1ll*a*a%M;
}
return res;
}
void work()
{
int cnt=0;
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
{
if(i==j) continue;
a[++cnt]=x[i]-x[j];
}
// printf("ksm:%lld",ksm(3,4));
// printf("cnt_%lld
",cnt);
a[0]=1;
for (int i=1;i<=cnt;i++)
b[i]=a[i],a[i]=a[i-1]*a[i]%M;
inv[cnt]=ksm(a[cnt],M-2);
for (int i=cnt-1;i>=0;i--)
inv[i]=1ll*inv[i+1]*b[i+1]%M;
cnt=0;
int ans=0;
for (int i=1;i<=n;i++)
{
int tmp=y[i];
for (int j=1;j<=n;j++)
{
if(i==j) continue;
tmp=1ll*tmp*(k-x[j])%M*(inv[++cnt]*a[cnt-1]%M)%M;
}
ans=(ans+tmp)%M;
}
printf("%lld
",(ans+M)%M);
}
signed main()
{
init();
work();
return 0;
}