Problem:
Problem I: Coin and Die
Problem
表と裏のあるコインと $1$ から $N$ までの目があるサイコロがある。Gachoくんはこれらを用いて以下のゲームをして遊ぶことにした。
ゲームは最初に得点が $0$ の状態から始まり、以下の手順で進められる。
サイコロを $1$ 回振り、そのとき出た目の数を得点に加算する
現在の得点が $K$ 以上ならゲームクリアとなりゲームを終了する
現在の得点が $K$ 未満ならコインを投げ表が出れば1.に戻り、裏が出ればゲームオーバーとなりゲームを終了する
コインは投げると $A\%$の確率で表になり、 $(100-A)\%$の確率で裏になる。また、サイコロは振ると、それぞれの目が等確率で出現する。
このとき、一度のゲームでGachoくんがゲームクリアすることができる確率を求めよ。
求める確率を互いに素な整数  $P, Q$ を用いて $\frac{P}{Q}$ と表したとき、 $R \times Q \equiv P\bmod 998244353$ となる $0$ 以上 $998244352$ 以下の整数 $R$ を出力せよ。この問題の制約下で、このような $R$ は必ず一意に存在する。
Input
入力は以下の形式で与えられる。
$N$ $K$ $A$
$N, K, A$ が空白区切りで一行に与えられる。
Constraints
入力は以下の条件を満たす。
$1 \leq N \leq 10^5 $
$1 \leq K \leq 10^5 $
$1 \leq A \leq 99 $
入力はすべて整数
Output
ゲームをクリアすることができる確率を互いに素な整数 $P, Q$を用いて $\frac{P}{Q}$ と表したとき、$R \times Q\equiv P\bmod 998244353$ となる $0$ 以上 $998244352$ 以下の整数 $R$ を出力せよ。
Sample Input 1
1 1 50
Sample Output 1
1
Sample Input 2
2 2 10
Sample Output 2
648858830
Sample Input 3
6 10 99
Sample Output 3
650893870

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
#define N (long long)(998244353)
#define MAX 500000
using namespace std;

long long factorial[MAX] = {0}, finverse[MAX] = {0},
          inverse[MAX] = {0};

void smodfact() {
  factorial[0] = factorial[1] = 1;
  finverse[0] = finverse[1] = 1;
  inverse[1] = 1;
  for(int i = 2; i < MAX; ++i) {
    factorial[i] = factorial[i - 1] * i % N;
    inverse[i] = N - (inverse[N % i] * (N / i)) % N;
    finverse[i] = finverse[i - 1] * inverse[i] % N;
  }
}

long long calccomb(long long n, long long k) {
  if(n == k && n == 0) return 1;
  if(n < 0 || k < 0 || n < k) return 0;
  return factorial[n] * finverse[k] % N * finverse[n - k] %
         N;
}

long long n, k, a;
long long dp[200005] = {0}, sum[200005] = {0};

long long solve();

int main() {
  cin >> n >> k >> a;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  smodfact();
  for(int i = 0; i <= n; ++i)
    dp[k + i] = 100 * inverse[a] % N;
  a *= inverse[100];
  a %= N;
  sum[k] = n;
  for(int i = k - 1; i >= 0; --i) {
    dp[i] = sum[i + 1] * inverse[n] % N;
    sum[i] = sum[i + 1] + dp[i] * a % N;
    sum[i] %= N;
    sum[i] -= dp[i + n] * a % N;
    sum[i] += N;
    sum[i] %= N;
  }
  return dp[0];
}
accuracy: 1
time_ms: 10
memory_kb: 17156
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


constexpr int bmds(int x){
  const int v[] = {1012924417, 924844033, 998244353,
                   897581057, 645922817};
  return v[x];
}
constexpr int brts(int x){
  const int v[] = {5, 5, 3, 3, 3};
  return v[x];
}


template<int X>
struct NTT{
  static constexpr int md = bmds(X);
  static constexpr int rt = brts(X);

  inline int add(int a,int b){
    a+=b;
    if(a>=md) a-=md;
    return a;
  }

  inline int mul(int a,int b){
    return 1LL*a*b%md;
  }

  inline int pow(int a,int b){
    int res=1;
    while(b){
      if(b&1) res=mul(res,a);
      a=mul(a,a);
      b>>=1;
    }
    return res;
  }

  inline int inv(int x){
    return pow(x,md-2);
  }

  // assume md % 4 = 1
  // if md % 4 == 3, then x = a^{(md+1)/4}
  inline int sqrt(int a){
    if(a==0) return 0;
    if(pow(a,(md-1)/2)!=1) return -1;
    int q=md-1,m=0;
    while(~q&1) q>>=1,m++;
    mt19937 mt;
    int z=mt()%md;
    while(pow(z,(md-1)/2)!=md-1) z=mt()%md;
    int c=pow(z,q),t=pow(a,q),r=pow(a,(q+1)/2);
    while(m>1){
      if(pow(t,1<<(m-2))!=1)
        r=mul(r,c),t=mul(t,mul(c,c));
      c=mul(c,c);
      m--;
    }
    return r;
  }

  vector<vector<int> > rts,rrts;

  void ensure_base(int n){
    if((int)rts.size()>=n) return;
    rts.resize(n);rrts.resize(n);
    for(int i=1;i<n;i<<=1){
      if(!rts[i].empty()) continue;
      int w=pow(rt,(md-1)/(i<<1));
      int rw=inv(w);
      rts[i].resize(i);rrts[i].resize(i);
      rts[i][0]=1;rrts[i][0]=1;
      for(int k=1;k<i;k++){
        rts[i][k]=mul(rts[i][k-1],w);
        rrts[i][k]=mul(rrts[i][k-1],rw);
      }
    }
  }

  void ntt(vector<int> &a,bool f,int n=-1){
    if(n==-1) n=a.size();
    assert((n&(n-1))==0);

    for(int i=0,j=1;j+1<n;j++){
      for(int k=n>>1;k>(i^=k);k>>=1);
      if(i>j) swap(a[i],a[j]);
    }

    for(int i=1;i<n;i<<=1){
      for(int j=0;j<n;j+=i*2){
        for(int k=0;k<i;k++){
          int z=mul(a[i+j+k],f?rrts[i][k]:rts[i][k]);
          a[i+j+k]=add(a[j+k],md-z);
          a[j+k]=add(a[j+k],z);
        }
      }
    }

    if(f){
      int tmp=inv(n);
      for(int i=0;i<n;i++) a[i]=mul(a[i],tmp);
    }
  }

  vector<int> add(vector<int> as,vector<int> bs){
    int sz=max(as.size(),bs.size());
    vector<int> cs(sz,0);
    for(int i=0;i<(int)as.size();i++) cs[i]=add(cs[i],as[i]);
    for(int i=0;i<(int)bs.size();i++) cs[i]=add(cs[i],bs[i]);
    return cs;
  }

  vector<int> sub(vector<int> as,vector<int> bs){
    int sz=max(as.size(),bs.size());
    vector<int> cs(sz,0);
    for(int i=0;i<(int)as.size();i++) cs[i]=add(cs[i],as[i]);
    for(int i=0;i<(int)bs.size();i++) cs[i]=add(cs[i],md-bs[i]);
    return cs;
  }

  vector<int> multiply(vector<int> as,vector<int> bs){
    int need=as.size()+bs.size()-1;
    int sz=1;
    while(sz<need) sz<<=1;
    ensure_base(sz);

    vector<int> f(sz),g(sz);
    for(int i=0;i<(int)as.size();i++) f[i]=as[i];
    for(int i=0;i<(int)bs.size();i++) g[i]=bs[i];
    ntt(f,0);ntt(g,0);
    for(int i=0;i<sz;i++) f[i]=mul(f[i],g[i]);
    ntt(f,1);

    f.resize(need);
    return f;
  }

  vector<int> divide(vector<int> as,vector<int> bs){
    assert(bs!=vector<int>(bs.size(),0));
    if(as==vector<int>(as.size(),0)) return {0};
    assert(as.size()>=bs.size());

    if(bs[0]==0){
      reverse(as.begin(),as.end());
      reverse(bs.begin(),bs.end());
      while(bs.back()==0){
        assert(as.back()==0);
        as.pop_back();
        bs.pop_back();
      }
      reverse(as.begin(),as.end());
      reverse(bs.begin(),bs.end());
    }

    int need=as.size()-bs.size()+1;
    as.resize(need);

    int sz=1;
    vector<int> rs({inv(bs[0])});
    while(sz<need){
      sz<<=1;
      vector<int> ts(min(sz,(int)bs.size()));
      for(int i=0;i<(int)ts.size();i++) ts[i]=bs[i];
      rs=sub(add(rs,rs),multiply(multiply(rs,rs),ts));
      rs.resize(sz);
    }

    while(as.back()==0) as.pop_back();
    while(rs.back()==0) rs.pop_back();
    auto cs=multiply(as,rs);
    cs.resize(need,0);
    return cs;
  }

  vector<int> sqrt(vector<int> as){
    if(as==vector<int>(as.size(),0)) return {0};

    int dg=0;
    if(as[0]==0){
      reverse(as.begin(),as.end());
      while(as.back()==0){
        dg++;
        as.pop_back();
        assert(as.back()==0);
        as.pop_back();
      }
      reverse(as.begin(),as.end());
    }

    int sz=1,inv2=inv(2);
    vector<int> ss({sqrt(as[0])});
    while(sz<(int)as.size()){
      sz<<=1;
      vector<int> ts(min(sz+sz/2-1,(int)as.size()));
      for(int i=0;i<(int)ts.size();i++) ts[i]=as[i];
      ss=add(ss,divide(ts,ss));
      ss.resize(sz);
      for(int &x:ss) x=mul(x,inv2);
    }

    if(dg){
      reverse(ss.begin(),ss.end());
      for(int i=0;i<dg;i++) ss.emplace_back(0);
      reverse(ss.begin(),ss.end());
    }
    return ss;
  }
};


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

  // find x s.t. a^x = b
  static T log(T a,T b){
    const T sq=40000;
    unordered_map<T, T> dp;
    dp.reserve(sq);
    Mint res(1);
    for(int r=0;r<sq;r++){
      if(!dp.count(res.v)) dp[res.v]=r;
      res*=a;
    }
    Mint p=Mint(a).inv().pow(sq);
    res=b;
    for(int q=0;q<=MOD/sq+1;q++){
      if(dp.count(res.v)){
        T idx=q*sq+dp[res.v];
        if(idx>0) return idx;
      }
      res*=p;
    }
    assert(0);
    return T(-1);
  }

  static Mint comb(long long n,int k){
    Mint num(1),dom(1);
    for(int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
signed main(){
  NTT<2> ntt;
  using M = Mint<int, decltype(ntt)::md>;

  int n,k,p100;
  cin>>n>>k>>p100;

  M p=M(p100)/M(100);

  vector<int> as(n+k+1,0);
  as[0]=(M(n)/p).v;

  vector<int> bs(n+1,(-p).v);
  bs[0]=n;

  auto cs=ntt.divide(as,bs);

  M ans{1};
  for(int i=1;i<k;i++) ans-=M(cs[i])*(M(1)-p);
  cout<<ans<<endl;
  return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 25384
final_rank: 17

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
//#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define MOD 998244353
#define NUM 100005

ll uniformity[8*NUM],partial[8*NUM];
ll N = 1;
ll first_N,K,P;

void init(ll first_N){
	while(N < first_N)N *= 2;
}

void add(ll left,ll right,ll value,ll node_id,ll node_left,ll node_right){

	if(right <= node_left || left >= node_right)return;
	else if(left <= node_left && right >= node_right){
		uniformity[node_id] += value;
		uniformity[node_id] %= MOD;
	}else{
		partial[node_id] += (min(right,node_right)-max(left,node_left))*value;
		partial[node_id] %= MOD;
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2,node_right);
	}
}

ll getSum(ll left,ll right,ll node_id,ll node_left,ll node_right){
	if(right <= node_left || left >= node_right)return 0;
	else if(left <= node_left && right >= node_right){
		return ((node_right-node_left)*uniformity[node_id]+partial[node_id])%MOD;

	}else{

		ll sum = (min(right,node_right)-max(left,node_left))*uniformity[node_id];
		sum %= MOD;

		sum += getSum(left,right,2*node_id+1,node_left,(node_left+node_right)/2);
		sum %= MOD;

		sum += getSum(left,right,2*node_id+2,(node_left+node_right)/2,node_right);
		sum %= MOD;

		return sum;
	}
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

int main(){

	scanf("%lld %lld %lld",&first_N,&K,&P);

	init(K+first_N);

	for(ll i = 0; i <= 2*N-2; i++){
		uniformity[i] = 0;
		partial[i] = 0;
	}

	ll inverse_N = mod_inverse(first_N,MOD);
	ll mult = mod_inverse(100*first_N,MOD)*P;
	mult %= MOD;

	//クリア状態
	for(ll i = K; i <= K+first_N-1; i++){

		add(i,i+1,1,0,0,N);
	}

	//i枚ある状態からクリアする確率を求める
	for(ll i = K-1; i >= 0; i--){

		ll tmp = 0;

		//1発でクリア状態に行ける場合
		if(i+first_N >= K){

			tmp += getSum(K,i+first_N+1,0,0,N);
			tmp *= inverse_N;
			tmp %= MOD;
		}

		ll tmp2 = 0;

		//クリア状態ではない状態に行ける場合
		if(i+1 <= K-1){

			tmp2 += getSum(i+1,min(K-1,i+first_N)+1,0,0,N);
			tmp2 *= mult;
			tmp2 %= MOD;
		}
		tmp += tmp2;
		tmp %= MOD;
		add(i,i+1,tmp,0,0,N);
	}

	printf("%lld\n",getSum(0,1,0,0,N)); //★注意:開区間★

	return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 11424
final_rank: 14

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

template<typename T>
struct BIT {
    int n;
    vector<T> dat;

    BIT(int n=0){
        initialize(n);
    }

    void initialize(int nin){
        n = nin;
        dat.resize(n, 0);
    }

    T sum(int i){
        T s = 0;
        while(i >= 0){
            add(s, dat[i]);
            i = (i & (i+1)) - 1;
        }
        return s;
    }

    T sum_between(int i, int j){
        return (MOD + sum(j) - sum(i-1)) % MOD;
    }

    void plus(int i, T x){
        while(i < n){
            add(dat[i], x);
            i |= i+1;
        }
    }
};

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main() {
    int N, K, A;
    cin >> N >> K >> A;
    BIT<int64_t> bit(N+K);
    int64_t c = A * inv_mod(100*N) % MOD;
    bit.plus(0, inv_mod(A) * 100 % MOD);
    for(int i=1; i<N+K; i++) bit.plus(i, bit.sum_between(max(0, i-N), min(K-1, i-1)) * c);
    int64_t ans = bit.sum_between(K, N+K-1);
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4356
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 998244353;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

ll dp[210000];

ll pow_mod(ll n, ll k, ll mod)
{
    if (k == 0)
    {
        return 1;
    }
    else if (k % 2 == 1)
    {
        return pow_mod(n, k - 1, mod) * n % mod;
    }
    else
    {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}

ll modinv(ll x)
{
    return pow_mod(x, MOD - 2, MOD);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, a;
    cin >> n >> k >> a;
    dp[0] = 1;
    for (ll i = 0; i < k; i++)
    {
        ll p = dp[i] * modinv(n) % MOD;
        if (i > 0)
        {
            (p *= a * modinv(100) % MOD) %= MOD;
        }
        (dp[i + 1] += p) %= MOD;
        (dp[i + n + 1] += MOD - p) %= MOD;
        if (i > 0)
        {
            (dp[i + 1] += dp[i]) %= MOD;
        }
    }
    ll ans = 0;
    for (ll i = k; i <= n + k; i++)
    {
        (ans += dp[i]) %= MOD;
        (dp[i + 1] += dp[i]) %= MOD;
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 140
memory_kb: 4772
final_rank: 15

code_snippet: /* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using graph = vector<vector<long long int>>;
using wgraph = vector<vector<pair<long long int, long long int>>>;
long long int INF = 1001001001001001LL;
long long int MOD = 998244353LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(long long int i = 0; i < (n); i++)
#define rrep(i,n) for(long long int i = 1; i <= (n); i++)
#define drep(i,n) for(long long int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(long long int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

// quoted from beet-aizu
template <typename T, typename E, typename F, typename G>
struct SegmentTree{
    // using F = function<T(T, T)>
    // using G = function<T(T, E)>
    int n;
    F f;
    G g;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f,G g,T ti):f(f),g(g),ti(ti){}
    void init(int n_){    
        n=1;
        while(n<n_) n<<=1;
        dat.assign(n<<1,ti);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    void update(int k,const E &x){
        k += n;
        dat[k] = g(dat[k], x);
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
    }
    T operator [](int k) const { return dat[k+n]; }
    T query(int a,int b) const {
        T vl=ti,vr=ti;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,dat[l++]);
            if(r&1) vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }

};


// 逆元を求める. a と m は互いに素であることが要請される.
lint modinv(lint a, lint m) {
    lint b = m, u = 1, v = 0;
    while(b){
        lint t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
  lint n, k, a; cin >> n >> k >> a;
  lint invn = modinv(n, MOD);
  lint inv100 = modinv(100, MOD);

  a = a * inv100;
  a %= MOD;

  using T = lint;  // type T
  using E = lint;  // type E
  auto f = [](T a, T b){ // return type T value
    return (a + b) % MOD;
  };
  auto g = [](T a, E b){ // return type T value
    return b % MOD;
  };
  T ti = 0;  // identify element
  SegmentTree<T, E, decltype(f), decltype(g)> sg(f, g, ti);  // don't change

  vector<lint> dat(n + k + 10, 0LL);
  dat[0] = 1LL;
  sg.build(dat);   // 初期配列を代入

  for(lint i = 1; i <= k + n + 2; i++) {
    lint l = max(0LL, i - n);
    lint r = min(k, i);
    lint sum = sg.query(l, r);
    sum = sum * invn % MOD;
    if(i < k) sum = sum * a % MOD;
    sg.update(i, sum);
  }

  cout << sg.query(k, k + n + 2) << endl;
}
accuracy: 1
time_ms: 70
memory_kb: 8348
final_rank: 11

code_snippet: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;

constexpr ll MOD = 998244353;

ll power(ll x, ll n){
    x %= MOD;
    ll res = 1;
    while(n > 0){
        if(n&1){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return power(x, MOD-2);
}

int main(){
    ll n, k, a;
    cin >> n >> k >> a;
    vector<ll> dp(k+n+2,0);  // dp[i] = 得点iになる確率
    dp[0] = 1;
    for(int i=0;i<k;i++){
        ll p = dp[i] * mod_inv(n) % MOD;
        if(i>0) p *= a*mod_inv(100) % MOD;
        p %= MOD;
        dp[i+1] += p;
        dp[i+n+1] += MOD-p;
        if(i>0) dp[i+1] += dp[i];
        dp[i+1] %= MOD;
        dp[i+n+1] %= MOD;
    }
    ll ans = 0;
    for(int i=k;i<=k+n;i++){
        ans += dp[i];
        ans %= MOD;
        dp[i+1] = ((dp[i+1]+dp[i])%MOD+MOD)%MOD;
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4356
final_rank: 3

code_snippet: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 998244353 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

ll power(int k, int n, int M){
  if(n == 0) return 1;
  if(n == 1) return (ll)k;

  ll res = power(k, n/2, M);

  res = res * res % M;
  return n%2 == 1 ? res * k % M : res;
}

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef ll Type;
  int segn2;
  vector<Type> data, s_data;
  function<Type(Type, Type)> merge;

  StarrySkyTree(function<Type(Type, Type)> merge, int n): merge(merge)
  {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 0);
    s_data.assign(segn2*2, 0);
  }

  StarrySkyTree(int n): //Original Ver.
    StarrySkyTree([](Type a, Type b){ return (a + b) % mod; }, n) {}

  //get value of [a,b)
  Type query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(r <= a || b <= l) return 0; //大きさに注意
    if(a <= l && r <= b) return (data[k] + s_data[k] * (r - l) % mod) % mod;
    return
      (merge(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2 , r, k*2+2)) +
      s_data[k] * max(0, min(b, r) - max(a, l)) % mod) % mod;
  }

  //add x to [a,b)
  Type add(int a, int b, Type x, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b) {
      s_data[k] += x;
      s_data[k] %= mod;
    } else if(a < r && l < b) {
      data[k] = merge(add(a, b, x, l, (l+r)/2, k*2+1), add(a, b, x, (l+r)/2, r, k*2+2));
    }

    return (data[k] + s_data[k] * (r - l)) % mod;
  }

};


int main(){
  int N, K, A;
  ll ans = 0;

  cin >> N >> K >> A;

  ll initEnvN = power(N, mod - 2, mod) % mod;
  ll invN = A * power(N * 100, mod - 2, mod) % mod;

  StarrySkyTree seg(K+1);

  int r = min(1+N, K);
  seg.add(1, r, initEnvN);
  ans += max(0, N+1 - r) * initEnvN;

  for(int i=1; i<K; i++) {
    ll p = seg.query(i, i+1);

    int r = min(i+N+1, K);
    seg.add(i+1, r, invN * p % mod);
    ans += max(0, i+N+1 - r) * invN % mod * p % mod;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 7088
final_rank: 9

code_snippet: #include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-conversion"

#define NDEBUG
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using uint = unsigned int;
using usize = std::size_t;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<typename T> constexpr T popcount(const T u) { return u ? static_cast<T>(__builtin_popcountll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T log2p1(const T u) { return u ? static_cast<T>(64 - __builtin_clzll(static_cast<u64>(u))) : static_cast<T>(0); }
template<typename T> constexpr T msbp1(const T u) { return log2p1(u); }
template<typename T> constexpr T lsbp1(const T u) { return __builtin_ffsll(u); }
template<typename T> constexpr T clog(const T u) { return u ? log2p1(u - 1) : static_cast<T>(u); }
template<typename T> constexpr bool ispow2(const T u) { return u and (static_cast<u64>(u) & static_cast<u64>(u - 1)) == 0; }
template<typename T> constexpr T ceil2(const T u) { return static_cast<T>(1) << clog(u); }
template<typename T> constexpr T floor2(const T u) { return u == 0 ? static_cast<T>(0) : static_cast<T>(1) << (log2p1(u) - 1); }
template<typename T> constexpr bool btest(const T mask, const usize ind) { return ((static_cast<u64>(mask) >> ind) & static_cast<u64>(1)); }
template<typename T> constexpr T bcut(const T mask, const usize ind) { return ind == 0 ? static_cast<T>(0) : static_cast<T>((static_cast<u64>(mask) << (64 - ind)) >> (64 - ind)); }
template<typename T> bool chmin(T& a, const T& b) { return (a > b ? a = b, true : false); }
template<typename T> bool chmax(T& a, const T& b) { return (a < b ? a = b, true : false); }
constexpr unsigned int mod                  = 1000000007;
template<typename T> constexpr T inf_v      = std::numeric_limits<T>::max() / 4;
template<typename Real> constexpr Real pi_v = Real{3.141592653589793238462643383279502884};
template<typename T>
T read()
{
    T v;
    return std::cin >> v, v;
}
template<typename T>
std::vector<T> read_vec(const std::size_t size)
{
    std::vector<T> v(size);
    for (auto& e : v) { std::cin >> e; }
    return v;
}
template<typename... Types>
auto read_vals() { return std::tuple<std::decay_t<Types>...>{read<Types>()...}; }
#define SHOW(...) static_cast<void>(0)
template<typename T>
std::vector<T> make_v(const std::size_t size, T v) { return std::vector<T>(size, v); }
template<class... Args>
auto make_v(const std::size_t size, Args... args) { return std::vector<decltype(make_v(args...))>(size, make_v(args...)); }


template<typename Real>
struct complex
{
    using value_type = Real;
    complex() : real{Real{0}}, imag{Real{0}} {}
    complex(const complex&) = default;
    complex(const Real& theta) : real(std::cos(theta)), imag(std::sin(theta)) {}
    complex(const Real& r, const Real& i) : real{r}, imag{i} {}
    ~complex() = default;
    friend complex operator+(const complex& c) { return c; }
    friend complex operator-(const complex& c) { return complex{-c.real, -c.imag}; }
    friend complex operator+(const complex& c1, const complex& c2) { return complex{c1.real + c2.real, c1.imag + c2.imag}; }
    friend complex operator-(const complex& c1, const complex& c2) { return complex{c1.real - c2.real, c1.imag - c2.imag}; }
    friend complex operator*(const complex& c1, const complex& c2) { return complex{c1.real * c2.real - c1.imag * c2.imag, c1.real * c2.imag + c1.imag * c2.real}; }
    friend complex operator*(const complex& c, const Real& r) { return complex{c.real * r, c.imag * r}; }
    friend complex operator/(complex& c1, complex& c2) { c1* c2.conj() / c2.norm(); }
    friend bool operator==(const complex& c1, const complex& c2) { return c1.real == c2.real and c1.imag == c2.imag; }
    friend bool operator!=(const complex& c1, const complex& c2) { return not(c1 == c2); }
    friend complex& operator+=(complex& c1, const complex& c2) { return c1.real += c2.real, c1.imag += c2.imag, c1; }
    friend complex& operator-=(complex& c1, const complex& c2) { return c1.real += c2.real, c1.imag += c2.imag, c1; }
    friend complex& operator*=(complex& c1, const complex& c2) { return c1 = c1 * c2; }
    friend complex& operator*=(complex& c, const Real& r) { return c = c * r; }
    friend complex& operator/=(complex& c1, const complex& c2) { return c1 = c1 / c2; }
    complex conj() const { return complex{real, -imag}; }
    Real norm() const { return real * real + imag * imag; }
    Real abs() const { return std::sqrt(norm()); }
    Real arg() const { return std::atan2(imag, real); }
    friend std::ostream& operator<<(std::ostream& os, const complex& c) { return os << c.real << "+" << c.imag << "i"; }
    Real real, imag;
};


template<typename T> T gcd(const T& a, const T& b) { return (a > b ? gcd(b, a) : a == 0 ? b : gcd(b % a, a)); }
template<typename T> T lcm(const T& a, const T& b) { return a / gcd(a, b) * b; }
template<typename T>
constexpr std::pair<T, T> extgcd(const T a, const T b)
{
    if (b == 0) { return std::pair<T, T>{1, 0}; }
    const auto g = gcd(a, b), da = std::abs(b) / g;
    const auto p = extgcd(b, a % b);
    const auto x = (da + p.second % da) % da, y = (g - a * x) / b;
    return {x, y};
}
template<typename T>
constexpr T inverse(const T a, const T mod) { return extgcd(a, mod).first; }
template<uint mod_value, bool dynamic = false>
class modint_base
{
public:
    template<typename UInt = uint>
    static std::enable_if_t<dynamic, const UInt> mod() { return mod_ref(); }
    template<typename UInt = uint>
    static constexpr std::enable_if_t<not dynamic, const UInt> mod() { return mod_value; }
    template<typename UInt = uint>
    static void set_mod(const std::enable_if_t<dynamic, const UInt> mod) { mod_ref() = mod, inv_ref() = {1, 1}; }
    modint_base() : v{0} {}
    modint_base(const ll val) : v{norm(static_cast<uint>(val % static_cast<ll>(mod()) + static_cast<ll>(mod())))} {}
    modint_base(const modint_base& n) : v{n()} {}
    explicit operator bool() const { return v != 0; }
    bool operator!() const { return not static_cast<bool>(*this); }
    modint_base& operator=(const modint_base& m) { return v = m(), (*this); }
    modint_base& operator=(const ll val) { return v = norm(uint(val % static_cast<ll>(mod()) + static_cast<ll>(mod()))), (*this); }
    friend modint_base operator+(const modint_base& m) { return m; }
    friend modint_base operator-(const modint_base& m) { return make(norm(mod() - m.v)); }
    friend modint_base operator+(const modint_base& m1, const modint_base& m2) { return make(norm(m1.v + m2.v)); }
    friend modint_base operator-(const modint_base& m1, const modint_base& m2) { return make(norm(m1.v + mod() - m2.v)); }
    friend modint_base operator*(const modint_base& m1, const modint_base& m2) { return make(static_cast<uint>(static_cast<ll>(m1.v) * static_cast<ll>(m2.v) % static_cast<ll>(mod()))); }
    friend modint_base operator/(const modint_base& m1, const modint_base& m2) { return m1 * inv(m2.v); }
    friend modint_base operator+(const modint_base& m, const ll val) { return modint_base{static_cast<ll>(m.v) + val}; }
    friend modint_base operator-(const modint_base& m, const ll val) { return modint_base{static_cast<ll>(m.v) - val}; }
    friend modint_base operator*(const modint_base& m, const ll val) { return modint_base{static_cast<ll>(m.v) * (val % static_cast<ll>(mod()))}; }
    friend modint_base operator/(const modint_base& m, const ll val) { return modint_base{static_cast<ll>(m.v) * inv(val)}; }
    friend modint_base operator+(const ll val, const modint_base& m) { return modint_base{static_cast<ll>(m.v) + val}; }
    friend modint_base operator-(const ll val, const modint_base& m) { return modint_base{-static_cast<ll>(m.v) + val}; }
    friend modint_base operator*(const ll val, const modint_base& m) { return modint_base{static_cast<ll>(m.v) * (val % static_cast<ll>(mod()))}; }
    friend modint_base operator/(const ll val, const modint_base& m) { return modint_base{val * inv(static_cast<ll>(m.v))}; }
    friend modint_base& operator+=(modint_base& m1, const modint_base& m2) { return m1 = m1 + m2; }
    friend modint_base& operator-=(modint_base& m1, const modint_base& m2) { return m1 = m1 - m2; }
    friend modint_base& operator*=(modint_base& m1, const modint_base& m2) { return m1 = m1 * m2; }
    friend modint_base& operator/=(modint_base& m1, const modint_base& m2) { return m1 = m1 / m2; }
    friend modint_base& operator+=(modint_base& m, const ll val) { return m = m + val; }
    friend modint_base& operator-=(modint_base& m, const ll val) { return m = m - val; }
    friend modint_base& operator*=(modint_base& m, const ll val) { return m = m * val; }
    friend modint_base& operator/=(modint_base& m, const ll val) { return m = m / val; }
    friend modint_base operator^(const modint_base& m, const ll n) { return power(m.v, n); }
    friend modint_base& operator^=(modint_base& m, const ll n) { return m = m ^ n; }
    friend bool operator==(const modint_base& m1, const modint_base& m2) { return m1.v == m2.v; }
    friend bool operator!=(const modint_base& m1, const modint_base& m2) { return not(m1 == m2); }
    friend bool operator==(const modint_base& m, const ll val) { return m.v == norm(static_cast<uint>(static_cast<ll>(mod()) + val % static_cast<ll>(mod()))); }
    friend bool operator!=(const modint_base& m, const ll val) { return not(m == val); }
    friend bool operator==(const ll val, const modint_base& m) { return m.v == norm(static_cast<uint>(static_cast<ll>(mod()) + val % static_cast<ll>(mod()))); }
    friend bool operator!=(const ll val, const modint_base& m) { return not(m == val); }
    friend std::istream& operator>>(std::istream& is, modint_base& m)
    {
        ll v;
        return is >> v, m = v, is;
    }
    friend std::ostream& operator<<(std::ostream& os, const modint_base& m) { return os << m(); }
    uint operator()() const { return v; }
    static modint_base small_inv(const usize n)
    {
        auto& in = inv_ref();
        if (n < in.size()) { return in[n]; }
        for (usize i = in.size(); i <= n; i++) { in.push_back(-in[modint_base::mod() % i] * (modint_base::mod() / i)); }
        return in.back();
    }

private:
    template<typename UInt = uint>
    static std::enable_if_t<dynamic, UInt&> mod_ref()
    {
        static UInt mod = 0;
        return mod;
    }
    static uint norm(const uint x) { return x < mod() ? x : x - mod(); }
    static modint_base make(const uint x)
    {
        modint_base m;
        return m.v = x, m;
    }
    static modint_base power(modint_base x, ull n)
    {
        modint_base ans = 1;
        for (; n; n >>= 1, x *= x) {
            if (n & 1) { ans *= x; }
        }
        return ans;
    }
    static modint_base inv(const ll v) { return v < 1000000 ? small_inv(static_cast<usize>(v)) : modint_base{inverse(v, static_cast<ll>(mod()))}; }
    static std::vector<modint_base>& inv_ref()
    {
        static std::vector<modint_base> in{1, 1};
        return in;
    }
    uint v;
};
template<uint mod>
using modint = modint_base<mod, false>;
template<uint id>
using dynamic_modint = modint_base<id, true>;
template<typename Real = double>
class fft
{
private:
    static constexpr usize depth = 30;
    static constexpr Real pi     = pi_v<Real>;
    static void transform(std::vector<complex<Real>>& a, const usize lg, const bool rev)
    {
        static std::vector<complex<Real>> root[depth];
        const usize sz = a.size();
        assert((1UL << lg) == sz);
        if (root[lg].empty()) {
            root[lg].reserve(sz), root[lg].resize(sz);
            for (usize i = 0; i < sz; i++) { root[lg][i] = complex<Real>(pi * Real(2 * i) / Real(sz)); }
        }
        std::vector<complex<Real>> tmp(sz);
        for (usize w = (sz >> 1); w > 0; w >>= 1) {
            for (usize y = 0; y < (sz >> 1); y += w) {
                const complex<Real> r = rev ? root[lg][y].conj() : root[lg][y];
                for (usize x = 0; x < w; x++) {
                    const auto u = a[y << 1 | x], v = a[y << 1 | x | w] * r;
                    tmp[y | x] = u + v, tmp[y | x | (sz >> 1)] = u - v;
                }
            }
            std::swap(tmp, a);
        }
    }

public:
    using value_type = Real;
    fft()            = delete;
    template<typename T = ll, usize division = 2, typename I = int>
    static std::vector<T> convolute(const std::vector<I>& a, const std::vector<I>& b)
    {
        constexpr usize bitnum = (depth + division - 1) / division;
        const usize need = a.size() + b.size() - 1, lg = clog(need), sz = 1UL << lg;
        std::vector<complex<value_type>> x[division], y[division], tmp(sz);
        for (usize i = 0; i < division; i++) {
            x[i].reserve(sz), x[i].resize(sz), y[i].reserve(sz), y[i].resize(sz);
            std::fill(tmp.begin() + std::min(a.size(), b.size()), tmp.end(), complex<value_type>{});
            for (usize j = 0; j < a.size(); j++) { tmp[j].real = value_type((a[j] >> (bitnum * i)) & ((1 << bitnum) - 1)); }
            for (usize j = 0; j < b.size(); j++) { tmp[j].imag = value_type((b[j] >> (bitnum * i)) & ((1 << bitnum) - 1)); }
            transform(tmp, lg, false);
            for (usize j = 0; j < sz; j++) { tmp[j] *= value_type(0.5); }
            for (usize j = 0; j < sz; j++) {
                const usize k = j == 0 ? 0UL : sz - j;
                x[i][j] = complex<value_type>{tmp[j].real + tmp[k].real, tmp[j].imag - tmp[k].imag}, y[i][j] = complex<value_type>{tmp[j].imag + tmp[k].imag, -tmp[j].real + tmp[k].real};
            }
        }
        std::vector<complex<value_type>> z[division];
        for (usize i = 0; i < division; i++) { z[i].reserve(sz), z[i].resize(sz); }
        for (usize a = 0; a < division; a++) {
            for (usize b = 0; b < division; b++) {
                for (usize i = 0; i < sz; i++) {
                    if (a + b < division) {
                        z[a + b][i] += x[a][i] * y[b][i];
                    } else {
                        z[a + b - division][i] += x[a][i] * y[b][i] * complex<value_type>(0, 1);
                    }
                }
            }
        }
        for (usize i = 0; i < division; i++) { transform(z[i], lg, true); }
        std::vector<T> ans(need);
        T base = 1;
        for (usize k = 0; k < 2 * division - 1; k++, base *= (1LL << bitnum)) {
            for (usize i = 0; i < need; i++) {
                if (k < division) {
                    ans[i] += base * T(std::round(z[k][i].real / value_type(sz)));
                } else {
                    ans[i] += base * T(std::round(z[k - division][i].imag / value_type(sz)));
                }
            }
        }
        return ans;
    }
    template<uint mod, bool dynamic = false, usize division = 2>
    static std::vector<modint_base<mod, dynamic>> convolute(const std::vector<modint_base<mod, dynamic>>& a, const std::vector<modint_base<mod, dynamic>>& b)
    {
        using mint             = modint_base<mod, dynamic>;
        constexpr usize bitnum = (depth + division - 1) / division;
        const usize need = a.size() + b.size() - 1, lg = clog(need), sz = 1UL << lg;
        std::vector<complex<value_type>> x[division], y[division], tmp(sz);
        for (usize i = 0; i < division; i++) {
            x[i].reserve(sz), x[i].resize(sz), y[i].reserve(sz), y[i].resize(sz);
            std::fill(tmp.begin() + std::min(a.size(), b.size()), tmp.end(), complex<value_type>{});
            for (usize j = 0; j < a.size(); j++) { tmp[j].real = value_type((a[j]() >> (bitnum * i)) & ((1 << bitnum) - 1)); }
            for (usize j = 0; j < b.size(); j++) { tmp[j].imag = value_type((b[j]() >> (bitnum * i)) & ((1 << bitnum) - 1)); }
            transform(tmp, lg, false);
            for (usize j = 0; j < sz; j++) { tmp[j] *= value_type(0.5); }
            for (usize j = 0; j < sz; j++) {
                const usize k = j == 0 ? 0UL : sz - j;
                x[i][j] = complex<value_type>{tmp[j].real + tmp[k].real, tmp[j].imag - tmp[k].imag}, y[i][j] = complex<value_type>{tmp[j].imag + tmp[k].imag, -tmp[j].real + tmp[k].real};
            }
        }
        std::vector<complex<value_type>> z[division];
        for (usize i = 0; i < division; i++) { z[i].reserve(sz), z[i].resize(sz); }
        for (usize a = 0; a < division; a++) {
            for (usize b = 0; b < division; b++) {
                for (usize i = 0; i < sz; i++) {
                    if (a + b < division) {
                        z[a + b][i] += x[a][i] * y[b][i];
                    } else {
                        z[a + b - division][i] += x[a][i] * y[b][i] * complex<value_type>(0, 1);
                    }
                }
            }
        }
        for (usize i = 0; i < division; i++) { transform(z[i], lg, true); }
        std::vector<mint> ans(need);
        mint base = 1;
        for (usize k = 0; k < 2 * division - 1; k++, base *= (1LL << bitnum)) {
            for (usize i = 0; i < need; i++) {
                if (k < division) {
                    ans[i] += int((base * ll(std::round(z[k][i].real / value_type(sz))))());
                } else {
                    ans[i] += int((base * ll(std::round(z[k - division][i].imag / value_type(sz))))());
                }
            }
        }
        return ans;
    }
};

template<uint mod = 924844033, uint root = 5>
class ntt
{
private:
    using value_type             = modint<mod>;
    static constexpr usize depth = 30;
    static void transform(std::vector<value_type>& a, const usize lg, const bool rev)
    {
        const usize N = a.size();
        assert(1UL << lg == N);
        static std::vector<value_type> R[depth];
        if (R[lg].empty()) {
            R[lg].reserve(N), R[lg].resize(N, value_type(1));
            const value_type r = value_type(root) ^ ((mod - 1) / N);
            for (usize i = 1; i < N; i++) { R[lg][i] = R[lg][i - 1] * r; }
        }
        std::vector<value_type> tmp(N);
        for (usize w = (N >> 1); w > 0; w >>= 1) {
            for (usize y = 0; y < (N >> 1); y += w) {
                const value_type r = rev ? R[lg][y == 0 ? 0 : N - y] : R[lg][y];
                for (usize x = 0; x < w; x++) {
                    const auto u = a[y << 1 | x], v = a[y << 1 | x | w]() * r;
                    tmp[y | x] = u + v, tmp[y | x | (N >> 1)] = u - v;
                }
            }
            std::swap(tmp, a);
        }
        if (rev) {
            for (usize i = 0; i < N; i++) { a[i] /= value_type(N); }
        }
    }

public:
    ntt() = delete;
    static std::vector<value_type> convolute(const std::vector<value_type>& a, const std::vector<value_type>& b)
    {
        const usize need = a.size() + b.size() - 1, lg = clog(need), sz = 1UL << lg;
        std::vector<value_type> A(sz, 0), B(sz, 0);
        for (usize i = 0; i < a.size(); i++) { A[i] = a[i](); }
        for (usize i = 0; i < b.size(); i++) { B[i] = b[i](); }
        transform(A, lg, false), transform(B, lg, false);
        for (usize i = 0; i < sz; i++) { A[i] *= B[i]; }
        transform(A, lg, true);
        std::vector<value_type> ans(need);
        for (usize i = 0; i < need; i++) { ans[i] = int(A[i]()); }
        return ans;
    }
};
template<uint mod, uint root, bool dynamic, uint fft_division>
class poly_base
{
public:
    using value_type = modint_base<mod, dynamic>;
    poly_base() : v(0) {}
    poly_base(const value_type& r) : v{r} { shrink(); }
    poly_base(const std::vector<value_type>& v) : v{v} { shrink(); }
    poly_base(const std::initializer_list<value_type>&& list) : v{list} { shrink(); }
    std::vector<value_type> operator()() const { return v; }
    value_type& operator[](const usize i) { return v[i]; }
    const value_type& operator[](const usize i) const { return v[i]; }
    value_type at(const usize i) const { return i < size() ? v[i] : value_type(0); }
    friend poly_base operator+(const poly_base& p) { return p; }
    friend poly_base operator-(const poly_base& p)
    {
        std::vector<value_type> ans = p.v;
        for (auto& e : ans) { e = -e; }
        return poly_base(ans);
    }
    friend poly_base operator+(const poly_base& p, const poly_base& q)
    {
        const usize sz = std::max(p.size(), q.size());
        std::vector<value_type> ans(sz);
        for (usize i = 0; i < sz; i++) { ans[i] = p.at(i) + q.at(i); }
        return poly_base(ans);
    }
    friend poly_base operator-(const poly_base& p, const poly_base& q)
    {
        const usize sz = std::max(p.size(), q.size());
        std::vector<value_type> ans(sz);
        for (usize i = 0; i < sz; i++) { ans[i] = p.at(i) - q.at(i); }
        return poly_base(ans);
    }
    friend poly_base operator*(const poly_base& p, const poly_base& q) { return p.size() <= 300 or q.size() <= 300 ? naive_multiply(p, q) : fft_multiply(p, q); }
    friend poly_base operator*(const poly_base& p, const value_type& r)
    {
        std::vector<value_type> ans = p.v;
        for (auto& e : ans) { e *= r; }
        return poly_base(ans);
    }
    friend poly_base operator/(const poly_base& p, const value_type& r)
    {
        std::vector<value_type> ans = p.v;
        for (auto& e : ans) { e /= r; }
        return poly_base(ans);
    }
    friend poly_base operator>>(const poly_base& p, const usize s) { return p.divide_by_power(s); }
    friend poly_base operator<<(const poly_base& p, const usize s) { return p.multiply_power(s); }
    friend poly_base operator/(const poly_base& p, const poly_base& q) { return p.div(q); }
    friend poly_base operator%(const poly_base& p, const poly_base& q) { return p.rem(q); }
    friend poly_base& operator+=(poly_base& p, const poly_base& q) { return p = p + q; }
    friend poly_base& operator-=(poly_base& p, const poly_base& q) { return p = p - q; }
    friend poly_base& operator*=(poly_base& p, const poly_base& q) { return p = p * q; }
    friend poly_base& operator*=(poly_base& p, const value_type& r) { return p = p * r; }
    friend poly_base& operator/=(poly_base& p, const value_type& r) { return p = p / r; }
    friend poly_base& operator>>=(poly_base& p, const usize s) { return p = (p >> s); }
    friend poly_base& operator<<=(poly_base& p, const usize s) { return p = (p << s); }
    friend poly_base& operator/=(poly_base& p, const poly_base& q) { return p = p / q; }
    friend poly_base& operator%=(poly_base& p, const poly_base& q) { return p = p % q; }
    poly_base multiply_power(const usize s) const
    {
        const usize sz = size();
        if (sz == 0) { return poly_base(); }
        std::vector<value_type> ans(sz + s, 0);
        for (usize i = 0; i < sz; i++) { ans[i + s] = v[i]; }
        return poly_base(ans);
    }
    poly_base divide_by_power(const usize s) const
    {
        const usize N = size();
        if (N <= s) { return poly_base(); }
        std::vector<value_type> ans(N - s);
        for (usize i = 0; i < N - s; i++) { ans[i] = v[i + s]; }
        return poly_base(ans);
    }
    poly_base rem_by_power(const usize k) const { return size() <= k ? *this : poly_base(std::vector<value_type>(v.begin(), v.begin() + k)); }
    poly_base inverse(const usize k) const  // p(x)q(x)=1 (mod x^{2^k})
    {
        poly_base q{value_type(1) / v[0]};
        const auto T = poly_base{2};
        for (usize i = 1, j = 0; j < k; j++, i *= 2) { q = (q * (T - rem_by_power(2 * i) * q)).rem_by_power(2 * i); }
        return q;
    }
    template<typename Int>
    static poly_base rem_of_power(const Int k, const poly_base& p)  // x^k (mod p(x))
    {
        const usize B = p.size() * 2 - 1;
        const auto q  = p.pseudo_inv(B);
        poly_base ans{1};
        const usize D = log2p1<usize>(k);
        for (usize i = 0; i < D; i++) {
            if (k & (static_cast<Int>(1) << (D - i - 1))) { ans = (ans.multiply_power(1)).rem(p, q, B); }
            if (D - i - 1) { ans = (ans * ans).rem(p, q, B); }
        }
        return ans;
    }
    usize size() const { return v.size(); }
    friend std::ostream& operator<<(std::ostream& os, const poly_base& p)
    {
        if (p.size() == 0) { return os << "0"; }
        for (usize i = 0; i < p.size(); i++) { os << (i != 0 ? "+" : "") << p[i] << (i != 0 ? i == 1 ? "X" : "X^" + std::to_string(i) : ""); }
        return os;
    }

private:
    static std::vector<value_type> naive_convolute(const std::vector<value_type>& a, const std::vector<value_type>& b)
    {
        std::vector<value_type> ans(a.size() + b.size() - 1, 0);
        for (usize i = 0; i < a.size(); i++) {
            for (usize j = 0; j < b.size(); j++) { ans[i + j] += a[i] * b[j]; }
        }
        return ans;
    }
    static poly_base naive_multiply(const poly_base& p, const poly_base& q) { return p.size() == 0 or q.size() == 0 ? poly_base{} : poly_base{naive_convolute(p(), q())}; }
    template<typename Poly = poly_base>
    static std::enable_if_t<root == 0, Poly> fft_multiply(const poly_base& p, const poly_base& q) { return p.size() == 0 or q.size() == 0 ? poly_base() : poly_base{fft<double>::convolute<mod, dynamic, fft_division>(p(), q())}; }
    template<typename Poly = poly_base>
    static std::enable_if_t<root != 0, Poly> fft_multiply(const poly_base& p, const poly_base& q) { return p.size() == 0 or q.size() == 0 ? poly_base() : poly_base{ntt<mod, root>::convolute(p(), q())}; }
    poly_base rev(const usize l) const
    {
        std::vector<value_type> ans = v;
        ans.resize(l), std::reverse(ans.begin(), ans.end());
        return poly_base(ans);
    }
    poly_base div(const poly_base& q) const
    {
        assert(q.size() > 0);
        if (size() < q.size()) { return poly_base(); }
        const usize N = size();
        const auto iq = q.pseudoInv(N);
        return (*this * iq).divide_by_power(N - 1);
    }
    poly_base rem(const poly_base& q) const { return *this - div(q) * q; }
    poly_base rem(const poly_base& q, const poly_base& iq, const usize B) { return *this - q * ((*this * iq).divide_by_power(B - 1)); }
    void shrink()
    {
        for (; not v.empty() and v.back() == 0; v.pop_back()) {}
    }
    poly_base pseudo_inv(const usize B) const
    {
        const usize N = size();
        return rev(N).inverse(B + 2 > N ? clog(B - N + 2) : 0).rev(B + 1 - N);
    }
    std::vector<value_type> v;
};
template<uint mod, uint fft_division = 2>
using poly = poly_base<mod, 0, false, fft_division>;
template<uint mod, uint fft_division = 2>
using dynamic_poly = poly_base<mod, 0, true, fft_division>;
template<uint mod = 924844033, uint root = 5>
using ntt_poly = poly_base<mod, root, false, 0>;
int main()
{
    constexpr uint mod  = 998244353;
    constexpr uint root = 5;
    using mint          = modint<mod>;
    const auto n = read<usize>(), k = read<usize>();
    const auto ninv = mint(1) / n;
    const auto a    = read<mint>() / 100;
    std::vector<mint> c(n + 1, 1);
    for (usize i = 1; i <= n; i++) { c[i] = -a * ninv; }
    ntt_poly<mod, root> p(c);
    const auto q = p.inverse(clog(k));
    mint ans     = 0;
    for (usize i = (k >= n ? k - n : 0UL); i < k; i++) { ans += q.at(i) * (n + i - k + 1) * ninv; }
    std::cout << ans << std::endl;
    return 0;
}
accuracy: 1
time_ms: 120
memory_kb: 12960
final_rank: 16

code_snippet: #include <iostream>
#include <vector>

using std::vector;

template <int MOD>
class ModInt {
    using lint = long long;

public:
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const { return *this ^ (MOD - 2); }

    // increment / decrement
    ModInt& operator++() { return *this += 1; }
    ModInt& operator--() { return *this -= 1; }
    ModInt operator++(int) {
        ModInt before = *this;
        ++(*this);
        return before;
    }
    ModInt operator--(int) {
        ModInt before = *this;
        --(*this);
        return before;
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator%(const ModInt& x) const { return ModInt(*this) %= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt operator^(const ModInt& x) const { return ModInt(*this) ^= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator%=(const ModInt& x) {
        val %= x.val;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }
    ModInt& operator^=(const ModInt& x) {
        int n = x.val;
        ModInt b = *this;
        if (n < 0) n = -n, b = ~b;

        *this = 1;
        while (n > 0) {
            if (n & 1) *this *= b;
            n >>= 1;
            b *= b;
        }
        return *this;
    }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }
    bool operator<(const ModInt& b) const { return val < b.val; }
    bool operator<=(const ModInt& b) const { return val <= b.val; }
    bool operator>(const ModInt& b) const { return val > b.val; }
    bool operator>=(const ModInt& b) const { return val >= b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
};

using mint = ModInt<998244353>;

int main() {
    int n, k, a;
    std::cin >> n >> k >> a;
    mint succ = mint(a) / 100;

    vector<mint> dp(n + k), dpsum(n + k);
    dp[0] = dpsum[0] = 1;
    for (int i = 1; i < n + k; ++i) {
        mint prev = dpsum[std::min(i, k) - 1] -
                    (i - n - 1 >= 0 ? dpsum[i - n - 1] : 0);
        dp[i] = prev / n * succ;
        dpsum[i] = dpsum[i - 1] + dp[i];
    }

    mint ans = dpsum[n + k - 1] - dpsum[k - 1];
    std::cout << ans / succ << std::endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4356
final_rank: 3

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

template<::std::uint_fast64_t mod>
class ModInt{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    ModInt() : n(0) {}
    ModInt(value_type n_) : n(n_ % mod) {}
    ModInt(const ModInt& m) : n(m.n) {}

    template<typename T>
    explicit operator T() const { return static_cast<T>(n); }
    value_type get() const { return n; }

    friend ::std::ostream& operator<<(::std::ostream &os, const ModInt<mod> &a) {
        return os << a.n;
    }

    friend ::std::istream& operator>>(::std::istream &is, ModInt<mod> &a) {
        value_type x;
        is >> x;
        a = ModInt<mod>(x);
        return is;
    }

    bool operator==(const ModInt& m) const { return n == m.n; }
    bool operator!=(const ModInt& m) const { return n != m.n; }
    ModInt& operator*=(const ModInt& m){ n = n * m.n % mod; return *this; }

    ModInt pow(value_type b) const{
        ModInt ans = 1, m = ModInt(*this);
        while(b){
            if(b & 1) ans *= m;
            m *= m;
            b >>= 1;
        }
        return ans;
    }

    ModInt inv() const { return (*this).pow(mod-2); }
    ModInt& operator+=(const ModInt& m){ n += m.n; n = (n < mod ? n : n - mod); return *this; }
    ModInt& operator-=(const ModInt& m){ n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
    ModInt& operator/=(const ModInt& m){ *this *= m.inv(); return *this; }
    ModInt operator+(const ModInt& m) const { return ModInt(*this) += m; }
    ModInt operator-(const ModInt& m) const { return ModInt(*this) -= m; }
    ModInt operator*(const ModInt& m) const { return ModInt(*this) *= m; }
    ModInt operator/(const ModInt& m) const { return ModInt(*this) /= m; }
    ModInt& operator++(){ n += 1; return *this; }
    ModInt& operator--(){ n -= 1; return *this; }
    ModInt operator++(int){
        ModInt old(n);
        n += 1;
        return old;
    }
    ModInt operator--(int){
        ModInt old(n);
        n -= 1;
        return old;
    }
    ModInt operator-() const { return ModInt(mod-n); }
};


template<class ValueMonoid, class OperatorMonoid, class Modifier,
        template<class...> class Container=::std::vector>
class LazySegTree{
public:
    using value_structure = ValueMonoid;
    using value_type = typename value_structure::value_type;
    using operator_structure = OperatorMonoid;
    using operator_type = typename operator_structure::value_type;
    using modifier = Modifier;
    using const_reference = const value_type &;
    using container_value_type = Container<value_type>;
    using container_operator_type = Container<operator_type>;
    using size_type = typename container_value_type::size_type;

private:
    container_value_type tree;
    container_operator_type lazy;
    size_type size_, height;

    static size_type getsize(const size_type x){
        size_type ret = 1;
        while(ret < x)
            ret <<= 1;
        return ret;
    }

    static size_type getheight(const size_type x){
        size_type ret = 0;
        while((static_cast<size_type>(1) << ret) < x){
            ret++;
        }
        return ret;
    }

    inline static value_type calc(const value_type a, const value_type b){
        return value_structure::operation(a, b);
    }

    inline static void apply(operator_type &data, const operator_type a){
        data = operator_structure::operation(data, a);
    }

    inline static value_type reflect(const value_type v, const operator_type o){
        return modifier::operation(v, o);
    }

    void push(const size_type index){
        tree[index] = reflect(tree[index], lazy[index]);
        apply(lazy[index << 1], lazy[index]);
        apply(lazy[index << 1 | 1], lazy[index]);
        lazy[index] = operator_structure::identity();
    }

    void calc_node(const size_type index){
        if(tree.size() <= (index << 1 | 1)) return;
        assert(0 < index);
        tree[index] = calc(reflect(tree[index << 1],  lazy[index << 1]),
                           reflect(tree[index << 1 | 1], lazy[index << 1 | 1]));
    }

    void build(size_type index){
        while(index >>= 1){
            calc_node(index);
        }
    }

    void propagate(const size_type index){
        for(size_type shift = height; shift ; --shift){
            push(index >> shift);
        }
    }

    void rebuild(){
        for(size_type i = size_-1;i > 0;--i){
            calc_node(i);
        }
    }
public:
    LazySegTree() : size_(0), height(0), tree(), lazy(){}
    LazySegTree(const size_type size)
            : size_(size), height(getheight(size)),
              tree(size << 1, value_structure::initializer()),
              lazy(size << 1, operator_structure::identity()){
        rebuild();
    }
    template<class InputIterator>
    LazySegTree(InputIterator first, InputIterator last)
            : size_(::std::distance(first, last)){
        height = getheight(size_);
        tree = container_value_type(size_, value_structure::identity());
        lazy = container_operator_type(size_ << 1, operator_structure::identity());
        tree.insert(tree.end(), first, last);
        rebuild();
    }

    size_type size() const { return size_; }
    const_reference operator[](const size_type k){
        assert(k < size_);
        propagate(k+size_);
        tree[k+size_] = reflect(tree[k+size_], lazy[k+size_]);
        lazy[k+size_] = operator_structure::identity();
        return tree[k+size_];
    }

    value_type query(size_type l, size_type r){
        assert(l <= r);
        assert(0 <= l && l < size_);
        assert(0 <= r && r <= size_);
        value_type retl = value_structure::identity(),
                retr = value_structure::identity();
        l += size_;
        r += size_;
        propagate(l);
        build(l);
        propagate(r-1);
        build(r-1);
        for(; l < r ; l >>= 1, r >>= 1){
            if(l&1){
                retl = calc(retl, reflect(tree[l], lazy[l]));
                l++;
            }
            if(r&1){
                r--;
                retr = calc(reflect(tree[r], lazy[r]), retr);
            }
        }
        return calc(retl, retr);
    }

    void update(size_type l, size_type r, const operator_type& data){
        assert(l <= r);
        assert(0 <= l && l < size_);
        assert(0 <= r && r <= size_);
        l += size_;
        r += size_;
        propagate(l);
        propagate(r - 1);
        for(size_type l_ = l, r_ = r; l_ < r_ ; l_ >>= 1, r_ >>= 1){
            if(l_ & 1) apply(lazy[l_++], data);
            if(r_ & 1) apply(lazy[--r_], data);
        }
        build(l);
        build(r - 1);
    }

    template<class F>
    void update(size_type index, const F& f){
        assert(0 <= index && index < size());
        index += size_;
        propagate(index);
        tree[index] = f(::std::move(tree[index]));
        lazy[index] = operator_structure::identity();
        build(index);
    }

    void dump() {
        REP(i, tree.size()) {
            cout << "(" << tree[i] << " " << lazy[i] << ") ";
        }
        cout << endl;
    }

    /*
    template<class F>
    size_type search(const F& f) const { // [0, result) is True and [0, result-1) is not.
        if(f(value_structure::identity()))
            return 0;
        if(!f(tree[1]))
            return size_+1;
        value_type acc = value_structure::identity();
        size_type i = 1;
        while(i <
    }
    */
};

constexpr int64 mod = 998244353;
using Mint = ModInt<mod>;

class v_monoid {
public:
    using value_type = Mint;
    static value_type identity() { return 0; }
    static value_type initializer() { return 0; }
    static value_type operation(const value_type& a, const value_type& b){
        return a+b;
    }
};

class o_monoid {
public:
    using value_type = Mint;
    static value_type identity() { return 0; }
    static value_type operation(const value_type& a, const value_type& b){
        return a+b;
    }
};

class modifier {
public:
    static Mint operation(const Mint& a, const Mint& b){
        return a+b;
    }
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, K;
	Mint A;
	cin >> N >> K >> A;
	A /= 100;
	LazySegTree<v_monoid, o_monoid, modifier> lsg(N+K);
	lsg.update(0, [](const Mint& a) { return 1; });
	FOR(i, 0, K) {
	    Mint val = lsg.query(i, i+1)*(i == 0 ? 1 : A);
	    lsg.update(i+1, i+N+1, val/N);
	}
	Mint sum = 0;
	FOR(i, K, N+K) {
	    sum += lsg.query(i, i+1);
	}
	cout << lsg.query(K, N+K) << endl;
}
accuracy: 1
time_ms: 80
memory_kb: 9096
final_rank: 12

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

template<ll MOD>
struct modint {
    ll x;
    modint(): x(0) {}
    modint(ll y) : x(y>=0 ? y%MOD : y%MOD+MOD) {}
    static constexpr ll mod() { return MOD; }
    // e乗
    modint pow(ll e) {
        ll a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % MOD; e /= 2;}
            else {a = (a*p) % MOD; e--;}
        }
        return modint(a);
    }
    modint inv() const {
        ll a=x, b=MOD, u=1, y=1, v=0, z=0;
        while(a) {
            ll q = b/a;
            swap(z -= q*u, u);
            swap(y -= q*v, v);
            swap(b -= q*a, a);
        }
        return z;
    }
    // Comparators
    bool operator <(modint b) { return x < b.x; }
    bool operator >(modint b) { return x > b.x; }
    bool operator<=(modint b) { return x <= b.x; }
    bool operator>=(modint b) { return x >= b.x; }
    bool operator!=(modint b) { return x != b.x; }
    bool operator==(modint b) { return x == b.x; }
    // Basic Operations
    modint operator+(modint r) const { return modint(*this) += r; }
    modint operator-(modint r) const { return modint(*this) -= r; }
    modint operator*(modint r) const { return modint(*this) *= r; }
    modint operator/(modint r) const { return modint(*this) /= r; }
    modint &operator+=(modint r) {
        if((x += r.x) >= MOD) x -= MOD;
        return *this;
    }
    modint &operator-=(modint r) {
        if((x -= r.x) < 0) x += MOD;
        return *this;
    }
    modint &operator*=(modint r) {
    #if !defined(_WIN32) || defined(_WIN64)
        x = x * r.x % MOD; return *this;
    #endif
        unsigned long long y = x * r.x;
        unsigned xh = (unsigned) (y >> 32), xl = (unsigned) y, d, m;
        asm(
            "divl %4; nt"
            : "=a" (d), "=d" (m)
            : "d" (xh), "a" (xl), "r" (MOD)
        );
        x = m;
        return *this;
    }
    modint &operator/=(modint r) { return *this *= r.inv(); }
    // increment, decrement
    modint operator++() { x++; return *this; }
    modint operator++(signed) { modint t = *this; x++; return t; }
    modint operator--() { x--; return *this; }
    modint operator--(signed) { modint t = *this; x--; return t; }

    template<class T>
    friend modint operator*(T l, modint r) { return modint(l) *= r; }
    template<class T>
    friend modint operator+(T l, modint r) { return modint(l) += r; }
    template<class T>
    friend modint operator-(T l, modint r) { return modint(l) -= r; }
    template<class T>
    friend modint operator/(T l, modint r) { return modint(l) /= r; }
    template<class T>
    friend bool operator==(T l, modint r) { return modint(l) == r; }
    template<class T>
    friend bool operator!=(T l, modint r) { return modint(l) != r; }
    // Input/Output
    friend ostream &operator<<(ostream& os, modint a) { return os << a.x; }
    friend istream &operator>>(istream& is, modint &a) { return is >> a.x; }
    friend string to_frac(modint v) {
        static map<ll, PII> mp;
        if(mp.empty()) {
            mp[0] = mp[MOD] = {0, 1};
            FOR(i, 2, 1001) FOR(j, 1, i) if(__gcd(i, j) == 1) {
                mp[(modint(i) / j).x] = {i, j};
            }
        }
        auto itr = mp.lower_bound(v.x);
        if(itr != mp.begin() && v.x - prev(itr)->first < itr->first - v.x) --itr;
        string ret = to_string(itr->second.first + itr->second.second * ((int)v.x - itr->first));
        if(itr->second.second > 1) {
            ret += '/';
            ret += to_string(itr->second.second);
        }
        return ret;
    }
};
using mint = modint<998244353>;

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, k, a0;
    cin >> n >> k >> a0;
    mint a = mint(a0) / 100;

    vector<mint> pro(n+k), rui(n+k);
    pro[1] = mint(1) / n;
    rui[1] = pro[1];
    FOR(i, 2, n+k) {
        mint temp = rui[min(k-1,i-1)]-rui[max(0LL,i-1-n)];
        temp *= a / n;
        if(i <= n) temp += mint(1) / n;

        pro[i] = temp;
        rui[i] = rui[i-1] + pro[i];
    }
    cout << rui[n+k-1] - rui[k-1] << endl;

    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 5936
final_rank: 7

code_snippet: /*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,A;
	cin >> N >> K >> A;
	Combination cb(10);
	ll sum[200010] = {};
	ll val[200010] = {};
	ll inv = cb.power(N, MOD-2);
	val[1] = inv;
	sum[1] = val[1];
	rep(i,2,N+K){
		ll tt = (sum[min(K-1, i-1)] - sum[max(0LL, i-N-1)] + MOD) % MOD;
		tt *= A * cb.power(100LL, MOD-2) % MOD * inv % MOD;
		tt %= MOD;
		if(i <= N){
			(tt += inv) %= MOD;
		}
		val[i] = tt;
		sum[i] = (sum[i-1] + val[i]) % MOD;
		sum[i] %= MOD;
	}
	ll ans = 0;
	rep(i,K,N+K){
		(ans += val[i]) %= MOD;
	}
	print(ans);
}
accuracy: 1
time_ms: 30
memory_kb: 6340
final_rank: 5

code_snippet: /*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
struct Combination{
private:
    ll N;
    vector<ll> fac, facinv;

public:
    Combination(ll n){
        N = n;
        fac.push_back(1); fac.push_back(1);
        rep(i,2,N+1) fac.push_back(fac[i-1] * i % MOD);
        rep(i,0,N+1) facinv.push_back(power(fac[i], MOD-2));
    }
    ll power(ll x, ll n){
        if(n == 0) return 1LL;
        ll res = power(x * x % MOD, n/2);
        if(n % 2 == 1) res = res * x % MOD;
        return res;
    }
    ll nck(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[k] % MOD * facinv[n-k] % MOD;
    }
    ll npk(ll n, ll k){
        if(k == 0 || n == k) return 1LL;
        return fac[n] * facinv[n-k] % MOD;
    }
    ll get(ll x){return fac[x];};
    ll getinv(ll x){return facinv[x];};
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,A;
	cin >> N >> K >> A;
	Combination cb(100010);
	ll sum[100010] = {};
	ll val[100010] = {};
	ll inv = cb.power(N, MOD-2);
	val[1] = inv;
	sum[1] = val[1];
	rep(i,2,N+K){
		ll tt = (sum[min(K-1, i-1)] - sum[max(0LL, i-N-1)] + MOD) % MOD;
		tt *= A * cb.power(100LL, MOD-2) % MOD * inv % MOD;
		tt %= MOD;
		if(i <= N){
			(tt += inv) %= MOD;
		}
		val[i] = tt;
		sum[i] = (sum[i-1] + val[i]) % MOD;
		sum[i] %= MOD;
	}
	ll ans = 0;
	rep(i,K,N+K){
		(ans += val[i]) %= MOD;
	}
	print(ans);
}
accuracy: 0.5217391304347826
time_ms: 30
memory_kb: 6052
final_rank: 19

code_snippet: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

int main() {
    ll n, k, a;
    cin >> n >> k >> a;
    a = divll(a, 100);
    VL dp(k + 1);
    dp[0] = dp[1] = 1;
    ll s = 1, j = 1;
    FOR(i,2,k){
        if (j < i - n){
            s = (s - dp[j] + mod) % mod;
            j++;
        }
        ll t = s;
        dp[i] = divll(s * a, n);
        if (i <= n) dp[i] = (dp[i] + divll(n - i + 1, n)) % mod;
        s = (s + dp[i]) % mod;
    }
    cout << dp[k] << endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3564
final_rank: 2

code_snippet: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 998244353 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

vector<ll> factmemo, factmemoInv;
ll factmemoMod = -1;

ll factorial(int n, int M){
  if(factmemoMod == M) return factmemo[n];
  if(n <= 1) return 1;

  ll res = 1;
  for(int i=1; i<=n; i++) res = res * i % M;
  return res;
}

ll power(int k, int n, int M){
  if(n == 0) return 1;
  if(n == 1) return (ll)k;

  ll res = power(k, n/2, M);

  res = res * res % M;
  return n%2 == 1 ? res * k % M : res;
}

void initFactorial(int n, int M){
  factmemo.assign(n+1, 0);
  factmemoInv.assign(n+1, 0);
  factmemoMod = M;
  factmemo[0] = 1;
  for(int i=1;i<=n;i++) factmemo[i] = factmemo[i-1] * i % M;
  factmemoInv[n] = power(factmemo[n], M-2, M);
  for(int i=n;i>0;i--) factmemoInv[i-1] = factmemoInv[i] * i % M;
}

//nCm nPm nHm (mod M)

/*Combination*/
ll C(int n, int m, int M){
  if(n < m) return 0;
  if(m == 0 || n == m) return 1;

  if(factmemoMod == M)
    return factmemo[n] * factmemoInv[m] % M * factmemoInv[n-m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(m, M) * factorial(n-m, M) % M;

  denom = power((int)denom, M-2, M);

  return numer * denom % M;
}

/*Permutation*/
ll P(int n, int m, int M){
  if(n < m) return 0;
  if(m == 0) return 1;

  if(factmemoMod == M)
    return factmemo[n] * factmemoInv[n-m] % M;

  ll numer = factorial(n, M);
  ll denom = factorial(n-m, M);

  denom = power((int)denom, M-2, M);

  return numer * denom % M;
}

/*Combination with Repetitions*/
ll H(int n, int m, int M){
  if(n == 0 && m == 0) return 1;
  return C(n+m-1, m, M);
}


/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef ll Type;
  int segn2;
  vector<Type> data, s_data;
  function<Type(Type, Type)> merge;

  StarrySkyTree(function<Type(Type, Type)> merge, int n): merge(merge)
  {
    for(segn2=1; segn2<n; segn2*=2);
    data.assign(segn2*2, 0);
    s_data.assign(segn2*2, 0);
  }

  StarrySkyTree(int n): //Original Ver.
    StarrySkyTree([](Type a, Type b){ return (a + b) % mod; }, n) {}

  //get value of [a,b)
  Type query(int a, int b, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(r <= a || b <= l) return 0; //大きさに注意
    if(a <= l && r <= b) return (data[k] + s_data[k] * (r - l) % mod) % mod;
    return
      (merge(query(a, b, l, (l+r)/2, k*2+1), query(a, b, (l+r)/2 , r, k*2+2)) +
      s_data[k] * max(0, min(b, r) - max(a, l)) % mod) % mod;
  }

  //add x to [a,b)
  Type add(int a, int b, Type x, int l = 0, int r = -1, int k = 0){
    if(r == -1) r = segn2;
    if(a <= l && r <= b) {
      s_data[k] += x;
      s_data[k] %= mod;
    } else if(a < r && l < b) {
      data[k] = merge(add(a, b, x, l, (l+r)/2, k*2+1), add(a, b, x, (l+r)/2, r, k*2+2));
    }

    return (data[k] + s_data[k] * (r - l)) % mod;
  }

};


int main(){
  int N, K, A;
  ll ans = 0;

  cin >> N >> K >> A;

  //initFactorial(N+1, mod);

  ll initEnvN = power(N, mod - 2, mod) % mod;
  ll invN = A * power(N * 100, mod - 2, mod) % mod;

  StarrySkyTree seg(K+1);

  int r = min(1+N, K);
  seg.add(1, r, initEnvN);
  ans += max(0, N+1 - r) * initEnvN;


  for(int i=1; i<K; i++) {
    ll p = seg.query(i, i+1);

    int r = min(i+N+1, K);
    seg.add(i+1, r, invN * p % mod);
    ans += max(0, i+N+1 - r) * invN % mod * p % mod;
    ans %= mod;

    debug(i+1);
    debug(r);
    debug(i+N+1);
  }

  cout << ans << endl;

  return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 7084
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void extended_euclid(ll x,ll y,ll *c,ll *a,ll *b){
  ll a0,a1,a2,b0,b1,b2,r0,r1,r2,q;r0=x;r1=y;a0=1;a1=0;b0=0;b1=1;
  while(r1>0){q=r0/r1;r2=r0%r1;a2=a0-q*a1;b2=b0-q*b1;r0=r1;r1=r2;a0=a1;a1=a2;b0=b1;b1=b2;}
  *c=r0;*a=a0;*b=b0;
}

ll get_inv(ll n, ll p){
  ll a,b,c;
  extended_euclid(n,p,&c,&a,&b);
  if(a<p) a+=p;
  return a%p;
}

int N=1<<18;
class StarrySkyTree{
public:
  ll Mi[555555],A[555555];
  void init(){memset(Mi,0,sizeof(Mi)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      A[k]%=MAX;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2])%MAX;
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return MAX;if(a<=l&&r<=b)return (Mi[k]+A[k])%MAX;
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return (min(left,right)+A[k])%MAX;
  }
};

StarrySkyTree t,r;

void Main() {
  t.init();
  r.init();
  ll n,m,a;
  cin >> n >> m >> a;
  t.add(0,1,1);
  r.add(0,1,1);
  rep(i,m) {
    ll x=t.getMin(i,i+1);
    t.add(i+1,min(m,i+n+1),x*a%MAX*get_inv(100,MAX)%MAX*get_inv(n,MAX)%MAX);
    t.add(min(m,i+n+1),i+n+1,x*get_inv(n,MAX)%MAX);
  }
  ll ans=0;
  REP(i,m,m+n+1) {
    ans+=t.getMin(i,i+1);
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}
accuracy: 1
time_ms: 200
memory_kb: 20600
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=998244353,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void extended_euclid(ll x,ll y,ll *c,ll *a,ll *b){
  ll a0,a1,a2,b0,b1,b2,r0,r1,r2,q;r0=x;r1=y;a0=1;a1=0;b0=0;b1=1;
  while(r1>0){q=r0/r1;r2=r0%r1;a2=a0-q*a1;b2=b0-q*b1;r0=r1;r1=r2;a0=a1;a1=a2;b0=b1;b1=b2;}
  *c=r0;*a=a0;*b=b0;
}

ll get_inv(ll n, ll p){
  ll a,b,c;
  extended_euclid(n,p,&c,&a,&b);
  if(a<p) a+=p;
  return a%p;
}

int N=1<<18;
class StarrySkyTree{
public:
  ll Mi[555555],A[555555];
  void init(){memset(Mi,0,sizeof(Mi)),memset(A,0,sizeof(A));}
  void add(int a,int b,ll x,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l) return;
    if(a<=l&&r<=b){
      A[k]+=x;
      while(k){
        k=(k-1)/2;
        Mi[k]=min(Mi[k*2+1]+A[k*2+1],Mi[k*2+2]+A[k*2+2])%MAX;
      }
      return;
    }
    add(a,b,x,k*2+1,l,(l+r)/2);
    add(a,b,x,k*2+2,(l+r)/2,r);
  }
  ll getMin(int a,int b,int k=0,int l=0,int r=N) {
    if(r<=a||b<=l)return LLONG_MAX;if(a<=l&&r<=b)return (Mi[k]+A[k])%MAX;
    ll left=getMin(a,b,k*2+1,l,(l+r)/2),right=getMin(a,b,k*2+2,(l+r)/2,r);
    return (min(left,right)+A[k])%MAX;
  }
};

StarrySkyTree t,r;

void Main() {
  t.init();
  r.init();
  ll n,m,a;
  cin >> n >> m >> a;
  t.add(0,1,1);
  r.add(0,1,1);
  rep(i,m) {
    ll x=t.getMin(i,i+1);
    t.add(i+1,min(m,i+n+1),x*a%MAX*get_inv(100,MAX)%MAX*get_inv(n,MAX));
    t.add(min(m,i+n+1),i+n+1,x*get_inv(n,MAX));
  }
  ll ans=0;
  REP(i,m,m+n+1) {
    ans+=t.getMin(i,i+1);
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}
accuracy: 0.5
time_ms: 30
memory_kb: 20560
final_rank: 20

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

template<::std::uint_fast64_t mod>
class ModInt{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    ModInt() : n(0) {}
    ModInt(value_type n_) : n(n_ % mod) {}
    ModInt(const ModInt& m) : n(m.n) {}

    template<typename T>
    explicit operator T() const { return static_cast<T>(n); }
    value_type get() const { return n; }

    friend ::std::ostream& operator<<(::std::ostream &os, const ModInt<mod> &a) {
        return os << a.n;
    }

    friend ::std::istream& operator>>(::std::istream &is, ModInt<mod> &a) {
        value_type x;
        is >> x;
        a = ModInt<mod>(x);
        return is;
    }

    bool operator==(const ModInt& m) const { return n == m.n; }
    bool operator!=(const ModInt& m) const { return n != m.n; }
    ModInt& operator*=(const ModInt& m){ n = n * m.n % mod; return *this; }

    ModInt pow(value_type b) const{
        ModInt ans = 1, m = ModInt(*this);
        while(b){
            if(b & 1) ans *= m;
            m *= m;
            b >>= 1;
        }
        return ans;
    }

    ModInt inv() const { return (*this).pow(mod-2); }
    ModInt& operator+=(const ModInt& m){ n += m.n; n = (n < mod ? n : n - mod); return *this; }
    ModInt& operator-=(const ModInt& m){ n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
    ModInt& operator/=(const ModInt& m){ *this *= m.inv(); return *this; }
    ModInt operator+(const ModInt& m) const { return ModInt(*this) += m; }
    ModInt operator-(const ModInt& m) const { return ModInt(*this) -= m; }
    ModInt operator*(const ModInt& m) const { return ModInt(*this) *= m; }
    ModInt operator/(const ModInt& m) const { return ModInt(*this) /= m; }
    ModInt& operator++(){ n += 1; return *this; }
    ModInt& operator--(){ n -= 1; return *this; }
    ModInt operator++(int){
        ModInt old(n);
        n += 1;
        return old;
    }
    ModInt operator--(int){
        ModInt old(n);
        n -= 1;
        return old;
    }
    ModInt operator-() const { return ModInt(mod-n); }
};


template<class ValueMonoid, class OperatorMonoid, class Modifier,
        template<class...> class Container=::std::vector>
class LazySegTree{
public:
    using value_structure = ValueMonoid;
    using value_type = typename value_structure::value_type;
    using operator_structure = OperatorMonoid;
    using operator_type = typename operator_structure::value_type;
    using modifier = Modifier;
    using const_reference = const value_type &;
    using container_value_type = Container<value_type>;
    using container_operator_type = Container<operator_type>;
    using size_type = typename container_value_type::size_type;

private:
    container_value_type tree;
    container_operator_type lazy;
    size_type size_, height;

    static size_type getsize(const size_type x){
        size_type ret = 1;
        while(ret < x)
            ret <<= 1;
        return ret;
    }

    static size_type getheight(const size_type x){
        size_type ret = 0;
        while((static_cast<size_type>(1) << ret) < x){
            ret++;
        }
        return ret;
    }

    inline static value_type calc(const value_type a, const value_type b){
        return value_structure::operation(a, b);
    }

    inline static void apply(operator_type &data, const operator_type a){
        data = operator_structure::operation(data, a);
    }

    inline static value_type reflect(const value_type v, const operator_type o){
        return modifier::operation(v, o);
    }

    void push(const size_type index){
        tree[index] = reflect(tree[index], lazy[index]);
        apply(lazy[index << 1], lazy[index]);
        apply(lazy[index << 1 | 1], lazy[index]);
        lazy[index] = operator_structure::identity();
    }

    void calc_node(const size_type index){
        if(tree.size() <= (index << 1 | 1)) return;
        assert(0 < index);
        tree[index] = calc(reflect(tree[index << 1],  lazy[index << 1]),
                           reflect(tree[index << 1 | 1], lazy[index << 1 | 1]));
    }

    void build(size_type index){
        while(index >>= 1){
            calc_node(index);
        }
    }

    void propagate(const size_type index){
        for(size_type shift = height; shift ; --shift){
            push(index >> shift);
        }
    }

    void rebuild(){
        for(size_type i = size_-1;i > 0;--i){
            calc_node(i);
        }
    }
public:
    LazySegTree() : size_(0), height(0), tree(), lazy(){}
    LazySegTree(const size_type size)
            : size_(size), height(getheight(size)),
              tree(size << 1, value_structure::initializer()),
              lazy(size << 1, operator_structure::identity()){
        rebuild();
    }
    template<class InputIterator>
    LazySegTree(InputIterator first, InputIterator last)
            : size_(::std::distance(first, last)){
        height = getheight(size_);
        tree = container_value_type(size_, value_structure::identity());
        lazy = container_operator_type(size_ << 1, operator_structure::identity());
        tree.insert(tree.end(), first, last);
        rebuild();
    }

    size_type size() const { return size_; }
    const_reference operator[](const size_type k){
        assert(k < size_);
        propagate(k+size_);
        tree[k+size_] = reflect(tree[k+size_], lazy[k+size_]);
        lazy[k+size_] = operator_structure::identity();
        return tree[k+size_];
    }

    value_type query(size_type l, size_type r){
        assert(l <= r);
        assert(0 <= l && l < size_);
        assert(0 <= r && r <= size_);
        value_type retl = value_structure::identity(),
                retr = value_structure::identity();
        l += size_;
        r += size_;
        propagate(l);
        propagate(r-1);
        for(; l < r ; l >>= 1, r >>= 1){
            if(l&1){
                retl = calc(retl, reflect(tree[l], lazy[l]));
                l++;
            }
            if(r&1){
                r--;
                retr = calc(reflect(tree[r], lazy[r]), retr);
            }
        }
        return calc(retl, retr);
    }

    void update(size_type l, size_type r, const operator_type& data){
        assert(l <= r);
        assert(0 <= l && l < size_);
        assert(0 <= r && r <= size_);
        l += size_;
        r += size_;
        propagate(l);
        propagate(r - 1);
        for(size_type l_ = l, r_ = r; l_ < r_ ; l_ >>= 1, r_ >>= 1){
            if(l_ & 1) apply(lazy[l_++], data);
            if(r_ & 1) apply(lazy[--r_], data);
        }
        build(l);
        build(r - 1);
    }

    template<class F>
    void update(size_type index, const F& f){
        assert(0 <= index && index < size());
        index += size_;
        propagate(index);
        tree[index] = f(::std::move(tree[index]));
        lazy[index] = operator_structure::identity();
        build(index);
    }

    /*
    template<class F>
    size_type search(const F& f) const { // [0, result) is True and [0, result-1) is not.
        if(f(value_structure::identity()))
            return 0;
        if(!f(tree[1]))
            return size_+1;
        value_type acc = value_structure::identity();
        size_type i = 1;
        while(i <
    }
    */
};

constexpr int64 mod = 998244353;
using Mint = ModInt<mod>;

class v_monoid {
public:
    using value_type = Mint;
    static value_type identity() { return 0; }
    static value_type initializer() { return 0; }
    static value_type operation(const value_type& a, const value_type& b){
        return a+b;
    }
};

class o_monoid {
public:
    using value_type = Mint;
    static value_type identity() { return 0; }
    static value_type operation(const value_type& a, const value_type& b){
        return a+b;
    }
};

class modifier {
public:
    static Mint operation(const Mint& a, const Mint& b){
        return a+b;
    }
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, K;
	Mint A;
	cin >> N >> K >> A;
	A /= 100;
	LazySegTree<v_monoid, o_monoid, modifier> lsg(N+K+1);
	lsg.update(0, [](const Mint& a) { return 1; });
	FOR(i, 0, K) {
	    Mint val = lsg.query(i, i+1)*(i == 0 ? 1 : A);
	    lsg.update(i+1, i+N+1, val/N);
	}
	Mint sum = 0;
	FOR(i, K, N+K) {
	    sum += lsg.query(i, i+1);
	}
	cout << sum << endl;
}
accuracy: 1
time_ms: 60
memory_kb: 9088
final_rank: 10

code_snippet: #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int mod = MOD;
struct ModInt {
  unsigned val;
  ModInt(): val(0) {}
  ModInt(long long x) : val(x >= 0 ? x % mod : x % mod + mod) {}
  ModInt pow(long long exponent) {
    ModInt tmp = *this, res = 1;
    while (exponent > 0) {
      if (exponent & 1) res *= tmp;
      tmp *= tmp;
      exponent >>= 1;
    }
    return res;
  }
  ModInt &operator+=(const ModInt &rhs) { if((val += rhs.val) >= mod) val -= mod; return *this; }
  ModInt &operator-=(const ModInt &rhs) { if((val += mod - rhs.val) >= mod) val -= mod; return *this; }
  ModInt &operator*=(const ModInt &rhs) { val = (unsigned long long)val * rhs.val % mod; return *this; }
  ModInt &operator/=(const ModInt &rhs) { return *this *= rhs.inv(); }
  bool operator==(const ModInt &rhs) const { return val == rhs.val; }
  bool operator!=(const ModInt &rhs) const { return val != rhs.val; }
  bool operator<(const ModInt &rhs) const { return val < rhs.val; }
  bool operator<=(const ModInt &rhs) const { return val <= rhs.val; }
  bool operator>(const ModInt &rhs) const { return val > rhs.val; }
  bool operator>=(const ModInt &rhs) const { return val >= rhs.val; }
  ModInt operator-() const { return ModInt(-val); }
  ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
  ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
  ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
  ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
  friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.val; }
  friend istream &operator>>(istream &is, ModInt &rhs) { long long x; is >> x; rhs = ModInt(x); return is; }
private:
  ModInt inv() const {
    // if (__gcd((int)val, mod) != 1) assert(false);
    unsigned a = val, b = mod; int x = 1, y = 0;
    while (b) {
      unsigned tmp = a / b;
      swap(a -= tmp * b, b);
      swap(x -= tmp * y, y);
    }
    return ModInt(x);
  }
};
ModInt abs(const ModInt &x) { return x.val; }
struct Combinatorics {
  Combinatorics(int MAX = 5000000) {
    MAX <<= 1;
    fact.resize(MAX + 1);
    fact_inv.resize(MAX + 1);
    fact[0] = 1;
    FOR(i, 1, MAX + 1) fact[i] = fact[i - 1] * i;
    fact_inv[MAX] = ModInt(1) / fact[MAX];
    for (int i = MAX; i > 0; --i) fact_inv[i - 1] = fact_inv[i] * i;
  }
  ModInt nCk(int n, int k) {
    if (n < 0 || n < k || k < 0) return ModInt(0);
    return fact[n] * fact_inv[k] * fact_inv[n - k];
  }
  ModInt nPk(int n, int k) {
    if (n < 0 || n < k || k < 0) return ModInt(0);
    return fact[n] * fact_inv[n - k];
  }
  ModInt nHk(int n, int k) {
    if (n < 0 || k < 0) return ModInt(0);
    return (k == 0 ? ModInt(1) : nCk(n + k - 1, k));
  }
private:
  vector<ModInt> fact, fact_inv;
};

template <typename Monoid>
struct StarrySky {
  StarrySky(int sz, const Monoid &UNITY, const Monoid &DEFAULT = 0) : UNITY(UNITY), DEFAULT(DEFAULT) {
    init(sz);
    dat.assign((n << 1) - 1, DEFAULT);
  }

  StarrySky(const vector<Monoid> &a, const Monoid &UNITY, const Monoid &DEFAULT = 0) : UNITY(UNITY), DEFAULT(DEFAULT) {
    int a_sz = a.size();
    init(a_sz);
    dat.resize((n << 1) - 1);
    REP(i, a_sz) dat[n - 1 + i] = a[i];
    for (int i = n - 2; i >= 0; --i) dat[i] = min(dat[(i << 1) + 1], dat[(i << 1) + 2]);
  }

  void add(int a, int b, const Monoid &value) { add(a, b, value, 0, 0, n); }

  Monoid query(int a, int b) { return query(a, b, 0, 0, n); }

  Monoid value(int idx) {
    idx += n - 1;
    Monoid res = added[idx];
    while (idx > 0) {
      idx = (idx - 1) >> 1;
      res += added[idx];
    }
    return res;
  }

private:
  int n = 1;
  const Monoid UNITY, DEFAULT;
  vector<Monoid> dat, added;

  void init(int sz) {
    while (n < sz) n <<= 1;
    added.assign((n << 1) - 1, DEFAULT);
  }

  void add(int a, int b, const Monoid &value, int node, int left, int right) {
    if (right <= a || b <= left) return;
    if (a <= left && right <= b) {
      added[node] += value;
    } else {
      add(a, b, value, (node << 1) + 1, left, (left + right) >> 1);
      add(a, b, value, (node << 1) + 2, (left + right) >> 1, right);
      dat[node] = min(dat[(node << 1) + 1] + added[(node << 1) + 1], dat[(node << 1) + 2] + added[(node << 1) + 2]);
    }
  }

  Monoid query(int a, int b, int node, int left, int right) {
    if (right <= a || b <= left) return UNITY;
    if (a <= left && right <= b) return dat[node] + added[node];
    return min(query(a, b, (node << 1) + 1, left, (left + right) >> 1), query(a, b, (node << 1) + 2, (left + right) >> 1, right)) + added[node];
  }
};

// yet-to-be-fixed
// template <typename Abelian>
// struct RAQ {
//   RAQ(int n_, const Abelian &UNITY = 0) : n(n_), UNITY(UNITY) {
//     ++n;
//     dat.assign(n, UNITY);
//   }

//   void add(int left, int right, const Abelian &value) {
//     while (left < n) {
//       dat[left] += value;
//       left += left & -left;
//     }
//     ++right;
//     while (right < n) {
//       dat[right] += -value;
//       right += right & -right;
//     }
//   }

//   Abelian query(int idx) {
//     Abelian res = UNITY;
//     while (idx > 0) {
//       res += dat[idx];
//       idx -= idx & -idx;
//     }
//     return res;
//   }

// private:
//   int n;
//   const Abelian UNITY;
//   vector<Abelian> dat;
// };

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k, a; cin >> n >> k >> a;
  if (k == 1) {
    cout << 1 << '\n';
    return 0;
  }
  StarrySky<ModInt> ss(k, ModInt(0));
  ModInt ans = 0;
  ss.add(0, 1, 1);
  REP(i, k) {
    int len = i + n;
    ss.add(i + 1, min(i + n + 1, k), ss.value(i) / n * a / 100);
    if (len >= k) ans += ss.value(i) / n * (len - k + 1);
  }
  cout << ans << '\n';

  // RAQ<ModInt> raq(k);
  // ModInt ans = 0;
  // raq.add(1, 1, 1);
  // REP(i, k) {
  //   int len = i + n;
  //   raq.add(i + 2, min(i + n + 1, k), raq.query(i + 1) / n * a / 100);
  //   if (len >= k) ans += raq.query(i + 1) / n * (len - k + 1);
  // }
  // cout << ans << '\n';
  return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 4964
final_rank: 6