#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const ll MOD = 998244353;

// a^n mod MOD を計算
ll modpow(ll aa, ll n) {
    ll res = 1;

    while (n > 0) {
        if (n % 2 == 1) {
            res = res * aa % MOD;
        }

        aa = aa * aa % MOD;
        n /= 2;
    }

    return res;
}

vector<long long> W;
long long N,M;

int searchc(int mods,long long c,int d){
    //cは最初に1を入れる、dは0
    for(int i=d;i<N-M+1;i++){
        c=c*W[i]; c=c%mods;
        searchc(mods,c,i+1);
    }
    return c;
}

int searchf(int b,int mods,long long f,int d){
    //fは最初に1を入れる、dは0
    for(int i=d;i<N-M+1;i++){
        f=f*b; f=f%mods;
        searchf(b,mods,f,i+1);
    }
    return f;
}

int main() {
    long long K,a=0,e;
    int mod=998244353;
    cin>>N>>M>>K;
    for(int i=0;i<N;i++){
        cin>>e;
        W.push_back(e);
        a+=W[i];
    }
    int C=searchc(mod,1,0);
    int F=searchf(a,mod,1,0);


    // xの逆元を求める
    ll inv = modpow(F, MOD - 2);

    // y / x に相当する値
    ll z = C * inv % MOD;

    cout << z << endl;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: