标签:article new def html turn view note print ==
证明 :https://wenku.baidu.com/view/0f88088a172ded630b1cb6b4.html
http://www.ebola.pro/article/notes/Lagrange
#include<bits/stdc++.h> using namespace std; #define mod 998244353 #define ll long long #define maxn 2345 ll n,k,x[maxn],y[maxn],z,m,ans; ll qpow(ll a,ll b) { ll re=1; while(b) { if(b%2)re=(re*a)%mod; a=(a*a)%mod; b>>=1; } return re; } int main() { scanf("%lld%lld",&n,&k); for(int i=1; i<=n; i++) scanf("%lld%lld",&x[i],&y[i]); for(int i=1; i<=n; i++) { z=y[i],m=1; for(int j=1; j<=n; j++) { if(i==j)continue; z=(z*(k-x[j])%mod+mod)%mod; m=(m*(x[i]-x[j])%mod+mod)%mod; } ans=(ans+z*qpow(m,mod-2)%mod+mod)%mod; } printf("%lld\n",ans); return 0; }
标签:article new def html turn view note print ==
原文地址:https://www.cnblogs.com/SDUTNING/p/10261609.html