stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#define mod 998244353

using namespace std;

long long n,a,b,k,ans=0,anss[300005][3],fac[300005],cnt=0;

inline long long inv(long long b){  

    return b==1?1:(mod-mod/b)*inv(mod%b)%mod;

}

inline long long C(long long n,long long m){  

    long long t=(fac[m]*fac[n-m])%mod;

    return (fac[n]*inv(t))%mod;

}

inline void init(){

	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);

	fac[0]=1,fac[1]=1;

	for(int i=2;i<300005;i++) fac[i]=(fac[i-1]*i)%mod;

}

int main(){

	init();

	for(int i=0;i<=n;i++)

		if(k>=(i*a)&&(k-a*i)%b==0&&(k-a*i)/b<=n){

			anss[cnt][0]=i;

			anss[cnt++][1]=(k-a*i)/b;

		}

	for(int i=0;i<cnt;i++) ans=(ans+C(n,anss[i][0])*C(n,anss[i][1])%mod)%mod;

	printf("%lld\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.484266699372417x):
#include<bits/stdc++.h>

#define mod 998244353

#define ll long long

using namespace std;

int n,a,b,q[300005],x[300005],ans;

ll k;

int pow(int c,int p){

	int tot=1;

	while(p){

		if(p&1) tot=1ll*c*tot%mod;

		c=1ll*c*c%mod;

		p>>=1;

	}

	return tot;

}

int C(int A,int B){

	if(A==0) return 1; if(A>B||B-A>n) return 0; if(A==B) return 1;

	return 1ll*q[B]*x[A]%mod*x[B-A]%mod;

}

int main(){

	scanf("%d%d%d%lld",&n,&a,&b,&k);

	q[1]=1;for(int i=2;i<=n;++i) q[i]=1ll*q[i-1]*i%mod;

	x[n]=pow(q[n],mod-2);

	for(int i=n-1;i>=0;--i) x[i]=x[i+1]*1ll*(i+1)%mod;

	if(k==0){puts("1");return 0;}

	for(int i=1;i<=n;++i){

		ll j=k-1ll*i*a;

		if(j%b) continue;

		j/=b;

		ans=(ans+1ll*C(i,n)*C(j,n)%mod)%mod;

	}

	printf("%d",ans);

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 3e5+10;

const int mod = 998244353;



int n,a,b,k;

int g[N],rev[N];



long long binpow(int a,int x)

{

 

	long long res;

	if(x == 0) return 1;

	res = binpow(a,x/2) % mod;

	if(x % 2 == 0) return res*res % mod;

	else return ((a*res) % mod * res) % mod;

}



void add(long long &x, long long y) { x = (x + y) % mod; }



long long tohop(int k,int n)

{

	if(k < 0 || n < 0 || k > n) return 0;

	int val = g[n-k]*g[k] % mod;

	return (g[n] * binpow(val,mod-2)) % mod;

}



signed main()

{

	int ans = 0;

	cin>>n>>a>>b>>k;

	g[0] = 1;

	for(int i=1;i<N;i++)

	{

		g[i] = ((g[i-1] % mod) * (i % mod)) % mod;

	}



	for(int i=0;i<=n;i++)

	{

		if((k - a*i) % b == 0)

		{

			int j = (k-a*i)/b;

			int val = tohop(i,n) * tohop(j,n) % mod;

				add(ans, val);

		}

	}



	cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 1.1543796116112701x):
#include<bits/stdc++.h>

#define sl(x) scanf("%lld",&x)

#define pl(x) printf("%lld\n",x) 

using namespace std;

const int N = 1e6+5;

const int mod = 998244353;

const int INF = 0x3f3f3f3f;

typedef long long ll;

ll inv(ll b)

{

	if(b == 1)

	return 1;

	return (mod-mod/b)*inv(mod%b)%mod;

}

ll fac[N];

ll C(ll n,ll m)

{

	ll t = (fac[m]*fac[n-m])%mod;

	return (fac[n]*inv(t))%mod;

}

ll ans[N][2];

int main()

{

	ll n,i,a,b,k;

	fac[0] = 1;

	fac[1] = 1;

	for(i = 2;i <= 3e5+5;i++)

	fac[i] = (fac[i-1]*i)%mod;

	sl(n);sl(a);sl(b);sl(k);

	ll cnt = 0;

	for(i = 0;i <= n;i++)

	{

		if(k-(i*a) >= 0 && (k-a*i)%b == 0 && (k-a*i)/b <= n)

		{

			ans[cnt][0] = i;

			ans[cnt++][1] = (k-a*i)/b;

		}

	}

	ll res=0;

	for(i = 0;i < cnt;i++)

	{

		res = (res+C(n,ans[i][0])*C(n,ans[i][1])%mod)%mod;

	}

	pl(res);

}
// Slower C++ solution:
#include<bits/stdc++.h> 

#define rep(i,l,r) for (ll i=l;i<=r;i++)

#define per(i,l,r) for (ll i=l;i>=r;i--)

using namespace std;

typedef long long ll;

const ll mm=998244353;

const int N=300000;

ll fac[N+10],inv[N+10],ans,a,b,k,n;

ll Pow(ll x,ll y){

	ll ans=1;

	while (y){

		if (y&1) ans=ans*x%mm;

		x=x*x%mm;

		y/=2;

	}

	return ans;

}

ll C(ll n,ll m){

	if (n<m) return 0;

	return fac[n]*inv[m]%mm*inv[n-m]%mm;

}

int main(){

	fac[0]=1;

	rep(i,1,N) fac[i]=fac[i-1]*i%mm;

	inv[N]=Pow(fac[N],mm-2);

	per(i,N,1) inv[i-1]=inv[i]*i%mm;

	scanf("%lld",&n);

	scanf("%lld%lld%lld",&a,&b,&k);

	rep(y,0,n){

		ll res=b*y;

		if (k-res>=0&&(k-res)%a==0) {

			ll x=(k-res)/a;

			(ans+=C(n,x)*C(n,y)%mm)%=mm;

		}

	}

	printf("%lld\n",ans);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.713196813300025x):
#include<bits/stdc++.h>

#define sl(x) scanf("%lld",&x)

#define pl(x) printf("%lld\n",x) 

using namespace std;

const int N = 1e6+5;

const int mod = 998244353;

const int INF = 0x3f3f3f3f;

typedef long long ll;

ll inv(ll b)

{

	if(b == 1)

	return 1;

	return (mod-mod/b)*inv(mod%b)%mod;

}

ll fac[N];

ll C(ll n,ll m)

{

	ll t = (fac[m]*fac[n-m])%mod;

	return (fac[n]*inv(t))%mod;

}

ll ans[N][2];

int main()

{

	ll n,i,a,b,k;

	fac[0] = 1;

	fac[1] = 1;

	for(i = 2;i <= 3e5+5;i++)

	fac[i] = (fac[i-1]*i)%mod;

	sl(n);sl(a);sl(b);sl(k);

	ll cnt = 0;

	for(i = 0;i <= n;i++)

	{

		if(k-(i*a) >= 0 && (k-a*i)%b == 0 && (k-a*i)/b <= n)

		{

			ans[cnt][0] = i;

			ans[cnt++][1] = (k-a*i)/b;

		}

	}

	ll res=0;

	for(i = 0;i < cnt;i++)

	{

		res = (res+C(n,ans[i][0])*C(n,ans[i][1])%mod)%mod;

	}

	pl(res);

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define MOD 998244353

#define int long long

#define pb push_back

#define bw(i,r,l) for (int i=r-1;i>=l;i--)

#define fw(i,l,r) for (int i=l;i<r;i++)

using namespace std;

int n,a,b,k,fac[300001];

int getpow(int a,int p) {

	if (!p) return 1;

	int temp=getpow(a,p/2),ans=temp*temp; ans%=MOD;

	if (p&1) ans*=a; ans%=MOD;

	return ans;

}

int getC(int k,int n) {

	if (k>n||k<0) return 0;

	return fac[n]*getpow(fac[k]*fac[n-k]%MOD,MOD-2)%MOD;

}

signed main() {

	//freopen("aome.inp","r",stdin);

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin>>n>>a>>b>>k;

	fac[0]=1; fw (i,1,n+1) {fac[i]=fac[i-1]*i; fac[i]%=MOD;}

	int ans=0;

	fw (i,0,n+1) if (a*i<=k) {

		int temp=k-a*i; if (temp%b!=0) continue;

		int j=temp/b;

		ans+=getC(i,n)*getC(j,n); ans%=MOD;

	}

	cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 1.2121334626215294x):
#include<cstdio>

#define mod 998244353

typedef long long ll;

ll inv[300005],c[300005];

int main()

{

	ll n,a,b,k,ans=0;scanf("%lld%lld%lld%lld",&n,&a,&b,&k);

	inv[1]=1;for(ll i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;

	c[0]=1;for(ll i=1;i<=n;i++) c[i]=c[i-1]*(n-i+1)%mod*inv[i]%mod;

	for(ll i=0,j;i<=n;i++)

	{

		if(a*i>k) break;

		if((k-a*i)%b==0) j=(k-a*i)/b; else continue;

		if(j>n) continue;

		ans+=c[i]*c[j]%mod,ans%=mod;

	}

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define MOD 998244353

#define int long long

#define pb push_back

#define bw(i,r,l) for (int i=r-1;i>=l;i--)

#define fw(i,l,r) for (int i=l;i<r;i++)

using namespace std;

int n,a,b,k,fac[300001];

int getpow(int a,int p) {

	if (!p) return 1;

	int temp=getpow(a,p/2),ans=temp*temp; ans%=MOD;

	if (p&1) ans*=a; ans%=MOD;

	return ans;

}

int getC(int k,int n) {

	if (k>n||k<0) return 0;

	return fac[n]*getpow(fac[k]*fac[n-k]%MOD,MOD-2)%MOD;

}

signed main() {

	//freopen("aome.inp","r",stdin);

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin>>n>>a>>b>>k;

	fac[0]=1; fw (i,1,n+1) {fac[i]=fac[i-1]*i; fac[i]%=MOD;}

	int ans=0;

	fw (i,0,n+1) if (a*i<=k) {

		int temp=k-a*i; if (temp%b!=0) continue;

		int j=temp/b;

		ans+=getC(i,n)*getC(j,n); ans%=MOD;

	}

	cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 1.8812934718929621x):
#include <cstdio>

const long long MOD = 998244353;

const int MAXN = 300010;

long long fac[MAXN], ifac[MAXN];

long long exGCD(long long a, long long b, long long& x, long long& y) {

	if (b == 0) {

		x = 1;

		y = 0;

		return a;

	}

	long long g = exGCD(b, a % b, x, y);

	long long temp = x;

	x = y;

	y = temp - a / b * y;

	return g;

}

int inverse(long long a) {

	long long x, y;

	exGCD(a, MOD, x, y);

	return (x % MOD + MOD) % MOD;

}

long long C(long long n, long long m) {

	return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;

}

int main() {

	long long n, a, b, k;

	scanf("%lld%lld%lld%lld", &n, &a, &b, &k);

	fac[0] = 1;

	for (int i = 1; i <= n; ++i) {

		fac[i] = fac[i - 1] * i % MOD;

	}

	ifac[n] = inverse(fac[n]);

	for (int i = n; i >= 1; --i) {

		ifac[i - 1] = ifac[i] * i % MOD;

	}

	long long ans = 0;

	for (int i = 0; i <= n && i * a <= k; ++i) {

		if ((k - i * a) % b == 0 && (k - i * a) / b <= n) {

			ans = (ans + C(n, i) * C(n, (k - i * a) / b) % MOD) % MOD;

		}

	}

	printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int N = 3e5 + 5, mod = 998244353;

int fac[N];

int fp(int a, int p) {

	if (!p) return 1;

	int t = fp(a, p >> 1);

	t = (t * 1ll * t) % mod;

	if (p & 1) t = (t * 1ll * a) % mod;

	return t;

}

ll ncr(int n, int r) {

	return ((fac[n] * 1ll * fp(fac[r], mod - 2)) % mod * 1ll * fp(fac[n - r], mod - 2)) % mod;

}

int main() {

	ios_base::sync_with_stdio(0);

	cin.tie(0);

	fac[0] = 1;

	for (int i = 1; i < N; i++)

		fac[i] = (fac[i - 1] * 1ll * i) % mod;

	int n, a, b;

	ll k;

	int ans = 0;

	cin >> n >> a >> b >> k;

	for (int i = 0; i <= n; i++) {

		ll x = i * 1ll * a;

		if (x > k || (k - x) % b) continue;

		ll y = (k - x) / b;

		if (y > n) continue;

		ans = (ans + (ncr(n, i) * 1ll * ncr(n, y)) % mod) % mod;

	}

	cout << ans << endl;

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 4.046334507335358x):
#include <cstdio>

const long long MOD = 998244353;

const int MAXN = 300010;

long long fac[MAXN], ifac[MAXN];

long long exGCD(long long a, long long b, long long& x, long long& y) {

	if (b == 0) {

		x = 1;

		y = 0;

		return a;

	}

	long long g = exGCD(b, a % b, x, y);

	long long temp = x;

	x = y;

	y = temp - a / b * y;

	return g;

}

int inverse(long long a) {

	long long x, y;

	exGCD(a, MOD, x, y);

	return (x % MOD + MOD) % MOD;

}

long long C(long long n, long long m) {

	return fac[n] * ifac[m] % MOD * ifac[n - m] % MOD;

}

int main() {

	long long n, a, b, k;

	scanf("%lld%lld%lld%lld", &n, &a, &b, &k);

	fac[0] = 1;

	for (int i = 1; i <= n; ++i) {

		fac[i] = fac[i - 1] * i % MOD;

	}

	ifac[n] = inverse(fac[n]);

	for (int i = n; i >= 1; --i) {

		ifac[i - 1] = ifac[i] * i % MOD;

	}

	long long ans = 0;

	for (int i = 0; i <= n && i * a <= k; ++i) {

		if ((k - i * a) % b == 0 && (k - i * a) / b <= n) {

			ans = (ans + C(n, i) * C(n, (k - i * a) / b) % MOD) % MOD;

		}

	}

	printf("%lld\n", ans);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define MOD 998244353

#define int long long

#define pb push_back

#define bw(i,r,l) for (int i=r-1;i>=l;i--)

#define fw(i,l,r) for (int i=l;i<r;i++)

using namespace std;

int n,a,b,k,fac[300001];

int getpow(int a,int p) {

	if (!p) return 1;

	int temp=getpow(a,p/2),ans=temp*temp; ans%=MOD;

	if (p&1) ans*=a; ans%=MOD;

	return ans;

}

int getC(int k,int n) {

	if (k>n||k<0) return 0;

	return fac[n]*getpow(fac[k]*fac[n-k]%MOD,MOD-2)%MOD;

}

signed main() {

	//freopen("aome.inp","r",stdin);

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin>>n>>a>>b>>k;

	fac[0]=1; fw (i,1,n+1) {fac[i]=fac[i-1]*i; fac[i]%=MOD;}

	int ans=0;

	fw (i,0,n+1) if (a*i<=k) {

		int temp=k-a*i; if (temp%b!=0) continue;

		int j=temp/b;

		ans+=getC(i,n)*getC(j,n); ans%=MOD;

	}

	cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 1.8474761004014804x):
#include<cstdio>

using namespace std;



const int mod=998244353,maxn=3e5+7;

int a,b,n;

long long k;

long long x,y,ans;



long long c[maxn]={1},inv[maxn]={1},fac[maxn]={1};



long long poww(int x,int y)

{

	long long ans=1,base=x;

	while(y){

		if(y&1)ans=(ans*base)%mod;

		base=(base*base)%mod;

		y>>=1;

	}

	return ans;

}



void pre()

{

	fac[0]=1,fac[1]=1;

    for(int i=2;i<=n+1;i++) fac[i]=fac[i-1]*i%mod;

    inv[n+1]=poww(fac[n+1],mod-2);

    for(int i=n;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;

}



long long get_c(int x)

{

	return ((1ll*fac[n]*inv[n-x])%mod*inv[x])%mod;

}



int main()

{

//	freopen("a.txt","r",stdin);

	scanf("%d %d %d %lld",&n,&a,&b,&k);

	if(k==0){printf("1"); return 0;}

	pre();

	for(x=1;x<=n;++x){

		if((k-x*a)%b)continue;

		y=(k-a*x)/b;

		if(y>n||y<0)continue;

		ans+=get_c(x)*get_c(y);

		ans%=mod;

	}

	printf("%lld",ans%mod);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

const int N = 3e5 + 5, mod = 998244353;

int fac[N];

int fp(int a, int p) {

	if (!p) return 1;

	int t = fp(a, p >> 1);

	t = (t * 1ll * t) % mod;

	if (p & 1) t = (t * 1ll * a) % mod;

	return t;

}

ll ncr(int n, int r) {

	return ((fac[n] * 1ll * fp(fac[r], mod - 2)) % mod * 1ll * fp(fac[n - r], mod - 2)) % mod;

}

int main() {

	ios_base::sync_with_stdio(0);

	cin.tie(0);

	fac[0] = 1;

	for (int i = 1; i < N; i++)

		fac[i] = (fac[i - 1] * 1ll * i) % mod;

	int n, a, b;

	ll k;

	int ans = 0;

	cin >> n >> a >> b >> k;

	for (int i = 0; i <= n; i++) {

		ll x = i * 1ll * a;

		if (x > k || (k - x) % b) continue;

		ll y = (k - x) / b;

		if (y > n) continue;

		ans = (ans + (ncr(n, i) * 1ll * ncr(n, y)) % mod) % mod;

	}

	cout << ans << endl;

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 3.973599232771482x):
#include<cstdio>

using namespace std;



const int mod=998244353,maxn=3e5+7;

int a,b,n;

long long k;

long long x,y,ans;



long long c[maxn]={1},inv[maxn]={1},fac[maxn]={1};



long long poww(int x,int y)

{

	long long ans=1,base=x;

	while(y){

		if(y&1)ans=(ans*base)%mod;

		base=(base*base)%mod;

		y>>=1;

	}

	return ans;

}



void pre()

{

	fac[0]=1,fac[1]=1;

    for(int i=2;i<=n+1;i++) fac[i]=fac[i-1]*i%mod;

    inv[n+1]=poww(fac[n+1],mod-2);

    for(int i=n;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;

}



long long get_c(int x)

{

	return ((1ll*fac[n]*inv[n-x])%mod*inv[x])%mod;

}



int main()

{

//	freopen("a.txt","r",stdin);

	scanf("%d %d %d %lld",&n,&a,&b,&k);

	if(k==0){printf("1"); return 0;}

	pre();

	for(x=1;x<=n;++x){

		if((k-x*a)%b)continue;

		y=(k-a*x)/b;

		if(y>n||y<0)continue;

		ans+=get_c(x)*get_c(y);

		ans%=mod;

	}

	printf("%lld",ans%mod);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define int long long

using namespace std;



const int N = 3e5 + 5;

const int MOD = 998244353;



int n, a, b, k;

int fac[N], ifac[N];



int fpow(int x,int y) {

	int res = 1;

	while (y) {

		if (y & 1) res = res * x % MOD;

		x = x * x % MOD;

		y >>= 1;

	}

	return res;

}



void prec() {

	fac[0] = 1;

	for (int i = 1;i < N;++i) fac[i] = fac[i - 1] * i % MOD;

	ifac[N - 1] = fpow(fac[N - 1], MOD - 2);

	for (int i = N - 2;i >= 0;--i) ifac[i] = ifac[i + 1] * (i + 1) % MOD;

}



int C(int k,int n) {

	if (n < k || k < 0) return 0;

	return fac[n] * ifac[k] % MOD * ifac[n - k] % MOD;

}



signed main() {

	ios_base::sync_with_stdio(false);

	prec();

	cin >> n >> a >> b >> k;

	int res = 0;

	for (int x = 0;x <= n;++x) {

		if ((k - x * a) % b) continue;

		int y = (k - x * a) / b;

		res = (res + C(x, n) * C(y, n)) % MOD;

	}

	cout << res << '\n'

;}

// Faster C++ solution for the same problem (measured speedup: 3.118201275091237x):
#include<iostream>

using namespace std;

const int maxn = 3e5 + 5;

const int MOD = 998244353;

#define LL long long

LL n,a,b,k;

LL fac[maxn];

LL inv[maxn];

LL C(LL x){

    return (fac[n] * inv[x]%MOD) *inv[n-x] %MOD;

}

int main()

{

    cin>>n>>a>>b>>k;

    if(k == 0){

        cout<<1<<endl;

        return 0;

    }

    fac[0]=inv[0]=inv[1]=1;

	for (int i=2;i<=n;i++)

		inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;

	for (int i=1;i<=n;i++){

		fac[i]=1ll*fac[i-1]*i%MOD;

		inv[i]=1ll*inv[i-1]*inv[i]%MOD;

	}

	LL ans = 0;

    for(int red = 0;red<=n;red++){

        LL rest = k - red * a;

        LL blue = rest / b;

        if(rest % b == 0 && blue <= n && rest >= 0){

            ans = (ans + C(red) * C((LL)rest / b)) % MOD;

        }

    }

    cout<<ans<<endl;

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define int long long

using namespace std;



const int N = 3e5 + 5;

const int MOD = 998244353;



int n, a, b, k;

int fac[N], ifac[N];



int fpow(int x,int y) {

	int res = 1;

	while (y) {

		if (y & 1) res = res * x % MOD;

		x = x * x % MOD;

		y >>= 1;

	}

	return res;

}



void prec() {

	fac[0] = 1;

	for (int i = 1;i < N;++i) fac[i] = fac[i - 1] * i % MOD;

	ifac[N - 1] = fpow(fac[N - 1], MOD - 2);

	for (int i = N - 2;i >= 0;--i) ifac[i] = ifac[i + 1] * (i + 1) % MOD;

}



int C(int k,int n) {

	if (n < k || k < 0) return 0;

	return fac[n] * ifac[k] % MOD * ifac[n - k] % MOD;

}



signed main() {

	ios_base::sync_with_stdio(false);

	prec();

	cin >> n >> a >> b >> k;

	int res = 0;

	for (int x = 0;x <= n;++x) {

		if ((k - x * a) % b) continue;

		int y = (k - x * a) / b;

		res = (res + C(x, n) * C(y, n)) % MOD;

	}

	cout << res << '\n'

;}

// Faster C++ solution for the same problem (measured speedup: 1.7082662677808114x):
#include<bits/stdc++.h>

using namespace std;

const long long mod=998244353;

long long n,a,b,k,f[300001];

long long pow(long long a, long long b, long long MOD)

{

 long long x=1,y=a; 

 while(b > 0)

 	{

 		if(b%2 == 1)

 	{

 		x=(x*y);

 		if(x>MOD) x%=MOD;

 	}

 	y = (y*y);

 	if(y>MOD) y%=MOD; 

 	b /= 2;

 	}

 return x;

}

 

/* Modular Multiplicative Inverse

 Using Euler's Theorem

 a^(phi(m)) = 1 (mod m)

 a^(-1) = a^(m-2) (mod m) */

long long InverseEuler(long long n, long long MOD)

{

 return pow(n,MOD-2,MOD);

}

 

long long C(long long n, long long r, long long MOD)

{

 

 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;

}

int main(){

	cin>>n>>a>>b>>k;

	f[0]=1;

	for(int i=1;i<=300000;i++){

		f[i]=(f[i-1]*i)%mod;

	}

	long long ans=0;

	for(int i=0;i<=n;i++){

		if((k-(i*a))<0){

			break;

		}

		else{

			if((k-i*a)/b<=n&&(k-(i*a))%b==0){

				ans+=C(n,i,mod)*C(n,(k-i*a)/b,mod);

				ans%=mod;

			}

		}

	}

	cout<<ans;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define int long long

using namespace std;



const int N = 3e5 + 5;

const int MOD = 998244353;



int n, a, b, k;

int fac[N], ifac[N];



int fpow(int x,int y) {

	int res = 1;

	while (y) {

		if (y & 1) res = res * x % MOD;

		x = x * x % MOD;

		y >>= 1;

	}

	return res;

}



void prec() {

	fac[0] = 1;

	for (int i = 1;i < N;++i) fac[i] = fac[i - 1] * i % MOD;

	ifac[N - 1] = fpow(fac[N - 1], MOD - 2);

	for (int i = N - 2;i >= 0;--i) ifac[i] = ifac[i + 1] * (i + 1) % MOD;

}



int C(int k,int n) {

	if (n < k || k < 0) return 0;

	return fac[n] * ifac[k] % MOD * ifac[n - k] % MOD;

}



signed main() {

	ios_base::sync_with_stdio(false);

	prec();

	cin >> n >> a >> b >> k;

	int res = 0;

	for (int x = 0;x <= n;++x) {

		if ((k - x * a) % b) continue;

		int y = (k - x * a) / b;

		res = (res + C(x, n) * C(y, n)) % MOD;

	}

	cout << res << '\n'

;}

// Faster C++ solution for the same problem (measured speedup: 8.350922976833873x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define N 300010

#define Mod 998244353

#define LL long long

LL s1[N],s2[N];

LL find(LL x,LL y)

{

    LL ans=1;

    x=x%Mod;

    while(y)

    {

        if(y%2)

            ans=ans*x%Mod;

        x=x*x%Mod;

        y=y/2;

    }

    return ans;

}

int main()

{

    LL n,m,x,y;

    LL i,j,k;

    LL ans;

    scanf("%lld%lld%lld%lld",&n,&x,&y,&m);

    s1[0]=1;

    for(i=1;i<=n;i++)

        s1[i]=s1[i-1]*i%Mod;

    s2[n]=find(s1[n],Mod-2);

    for(i=n;i>=1;i--)

        s2[i-1]=s2[i]*i%Mod;

    ans=0;

    for(i=0;i<=n;i++)

    {

        if((m-i*x)%y!=0||(m-i*x<0)||(m-i*x)/y>n)

            continue;

        ans=(ans+s1[n]*s2[i]%Mod*s2[n-i]%Mod*s1[n]%Mod*s2[(m-i*x)/y]%Mod*s2[n-(m-i*x)/y]%Mod)%Mod;

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

const int maxn = 3e5 + 5;

const int MOD = 998244353;

#define LL long long

LL n,a,b,k;

LL fac[maxn];

LL inv[maxn];

LL C(LL x){

    return (fac[n] * inv[x]%MOD) *inv[n-x] %MOD;

}

int main()

{

    cin>>n>>a>>b>>k;

    if(k == 0){

        cout<<1<<endl;

        return 0;

    }

    fac[0]=inv[0]=inv[1]=1;

	for (int i=2;i<=n;i++)

		inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;

	for (int i=1;i<=n;i++){

		fac[i]=1ll*fac[i-1]*i%MOD;

		inv[i]=1ll*inv[i-1]*inv[i]%MOD;

	}

	LL ans = 0;

    for(int red = 0;red<=n;red++){

        LL rest = k - red * a;

        LL blue = rest / b;

        if(rest % b == 0 && blue <= n && rest >= 0){

            ans = (ans + C(red) * C((LL)rest / b)) % MOD;

        }

    }

    cout<<ans<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.678121852987033x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define N 300010

#define Mod 998244353

#define LL long long

LL s1[N],s2[N];

LL find(LL x,LL y)

{

    LL ans=1;

    x=x%Mod;

    while(y)

    {

        if(y%2)

            ans=ans*x%Mod;

        x=x*x%Mod;

        y=y/2;

    }

    return ans;

}

int main()

{

    LL n,m,x,y;

    LL i,j,k;

    LL ans;

    scanf("%lld%lld%lld%lld",&n,&x,&y,&m);

    s1[0]=1;

    for(i=1;i<=n;i++)

        s1[i]=s1[i-1]*i%Mod;

    s2[n]=find(s1[n],Mod-2);

    for(i=n;i>=1;i--)

        s2[i-1]=s2[i]*i%Mod;

    ans=0;

    for(i=0;i<=n;i++)

    {

        if((m-i*x)%y!=0||(m-i*x<0)||(m-i*x)/y>n)

            continue;

        ans=(ans+s1[n]*s2[i]%Mod*s2[n-i]%Mod*s1[n]%Mod*s2[(m-i*x)/y]%Mod*s2[n-(m-i*x)/y]%Mod)%Mod;

    }

    printf("%lld\n",ans);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const long long mod=998244353;

long long n,a,b,k,f[300001];

long long pow(long long a, long long b, long long MOD)

{

 long long x=1,y=a; 

 while(b > 0)

 	{

 		if(b%2 == 1)

 	{

 		x=(x*y);

 		if(x>MOD) x%=MOD;

 	}

 	y = (y*y);

 	if(y>MOD) y%=MOD; 

 	b /= 2;

 	}

 return x;

}

 

/* Modular Multiplicative Inverse

 Using Euler's Theorem

 a^(phi(m)) = 1 (mod m)

 a^(-1) = a^(m-2) (mod m) */

long long InverseEuler(long long n, long long MOD)

{

 return pow(n,MOD-2,MOD);

}

 

long long C(long long n, long long r, long long MOD)

{

 

 return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;

}

int main(){

	cin>>n>>a>>b>>k;

	f[0]=1;

	for(int i=1;i<=300000;i++){

		f[i]=(f[i-1]*i)%mod;

	}

	long long ans=0;

	for(int i=0;i<=n;i++){

		if((k-(i*a))<0){

			break;

		}

		else{

			if((k-i*a)/b<=n&&(k-(i*a))%b==0){

				ans+=C(n,i,mod)*C(n,(k-i*a)/b,mod);

				ans%=mod;

			}

		}

	}

	cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 4.888537070794273x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define N 300010

#define Mod 998244353

#define LL long long

LL s1[N],s2[N];

LL find(LL x,LL y)

{

    LL ans=1;

    x=x%Mod;

    while(y)

    {

        if(y%2)

            ans=ans*x%Mod;

        x=x*x%Mod;

        y=y/2;

    }

    return ans;

}

int main()

{

    LL n,m,x,y;

    LL i,j,k;

    LL ans;

    scanf("%lld%lld%lld%lld",&n,&x,&y,&m);

    s1[0]=1;

    for(i=1;i<=n;i++)

        s1[i]=s1[i-1]*i%Mod;

    s2[n]=find(s1[n],Mod-2);

    for(i=n;i>=1;i--)

        s2[i-1]=s2[i]*i%Mod;

    ans=0;

    for(i=0;i<=n;i++)

    {

        if((m-i*x)%y!=0||(m-i*x<0)||(m-i*x)/y>n)

            continue;

        ans=(ans+s1[n]*s2[i]%Mod*s2[n-i]%Mod*s1[n]%Mod*s2[(m-i*x)/y]%Mod*s2[n-(m-i*x)/y]%Mod)%Mod;

    }

    printf("%lld\n",ans);

    return 0;

}