3 条题解

  • 4
    #include <bits/stdc++.h>
    #define ll long long
    
    using namespace std;
    
    const int N=2e5+5;
    const int p=998244353;
    ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%p; m=m*m%p,b>>=1;} return s;}
    
    ll m,n,x,y,ans,fc[N],ifc[N];
    ll C(ll m,ll n){return fc[n+m-1]*ifc[n]%p*ifc[m-1]%p;}
    
    int main(){
    	cin>>m>>n>>x>>y;
    	fc[0]=1; for(int i=1;i<=m+n;i++)fc[i]=fc[i-1]*i%p;
    	ifc[m+n]=ksm(fc[m+n],p-2); for(int i=m+n-1;~i;i--)ifc[i]=ifc[i+1]*(i+1)%p;
    	if(x<=n&&y>n)for(int i=1;i<=m;i++)ans=(ans+C(i,x-1)*C(m-i+1,n-x)%p*C(m-i+1,y-n-1)%p*C(i,2*n-y))%p;
    	else ans=C(m,n)*C(m,n+x-y)%p;
    	cout<<ans<<endl;
    	return 0;
    }
    
    • -5
      @ 2024-5-18 10:29:14

      jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

      • -5
        @ 2024-3-27 16:42:34

        #include <bits/stdc++.h> #define ll long long

        using namespace std;

        const int N=2e5+5; const int p=998244353; ll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=sm%p; m=mm%p,b>>=1;} return s;}

        ll m,n,x,y,ans,fc[N],ifc[N]; ll C(ll m,ll n){return fc[n+m-1]ifc[n]%pifc[m-1]%p;}

        int main(){ cin>>m>>n>>x>>y; fc[0]=1; for(int i=1;i<=m+n;i++)fc[i]=fc[i-1]i%p; ifc[m+n]=ksm(fc[m+n],p-2); for(int i=m+n-1;~i;i--)ifc[i]=ifc[i+1](i+1)%p; if(x<=n&&y>n)for(int i=1;i<=m;i++)ans=(ans+C(i,x-1)C(m-i+1,n-x)%pC(m-i+1,y-n-1)%pC(i,2n-y))%p; else ans=C(m,n)*C(m,n+x-y)%p; cout<<ans<<endl; return 0; }

        • 1

        [NOI Online #2 入门组] 建设城市

        信息

        ID
        1801
        时间
        1000ms
        内存
        256MiB
        难度
        1
        标签
        递交数
        70
        已通过
        51
        上传者