Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

const ll MAX = 100001;
const ll MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(ll n, ll k){
    if (n < k) return (pow(n,k))%MOD;
    if(k!=1) return (n+(k*(fac[n] * (finv[k] * finv[n - k] % MOD) % MOD)%MOD))%MOD;
  	else return (fac[n] *(finv[k] * finv[n - k] % MOD) % MOD);
}
int main(){
    ll n;cin >> n;
    ll d[n];
  	rep(i,0,n)cin >> d[i];
    //最初は0確定
    if(d[0] != 0){
        cout<<0<<endl;
        return 0;
    }
    //他に0を含んでいてもだめ
    rep(i,1,n){
        if(d[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    
    sort(d,d+n);
    ll res = 1;
    vector<ll> v; ll cnt=1,tmp=1;
  	v.pb(1);
    rep(i,1,n){
        if(d[i] == cnt+1){
            v.pb(i-tmp);
            tmp =i;cnt++;
        }if(i==n-1 ){
            v.pb(n-tmp);
        }
    }
  	COMinit();
  	//rep(i,0,v.size())cout<<v[i]<<ednl;
    rep(i,1,v.size()){
      	//cout << v[i] << " " << v[i-1] << endl;
        res = (res * (COM(v[i-1],v[i]) % MOD )) % MOD;
      	//cout << v[i-1] << " " << v[i] << " " << res << ednl;
        // ll sum=0;
        // rep(j,0,v[i]+1) sum+=COM(v[i], j);
        // res *= 
    }
    cout << res << endl;
}


Compiler output:
a.cc: In function 'long long int COM(long long int, long long int)':
a.cc:45:33: error: invalid operands of types '__gnu_cxx::__promote<double>::__type' {aka 'double'} and 'const long long int' to binary 'operator%'
   45 |     if (n < k) return (pow(n,k))%MOD;
      |                       ~~~~~~~~~~^~~~
      |                           |      |
      |                           |      const long long int
      |                           __gnu_cxx::__promote<double>::__type {aka double}