Language: C++

#include <bits/stdc++.h>
#define F first
//#define S second
#define dq deque
#define vc vector
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define Pb push_back
#define Mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define Pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pii pair<int,int>
#define uint unsigned int
#define All(x) x.begin(),x.end()
//#define B cout << "BreakPoint" << endl;
#define Fin(a) freopen(a,"r",stdin)
#define Fout(a) freopen(a,"w",stdout)
#define Ms(_data) memset(_data,0,sizeof(_data))
#define Msn(_data,_num) memset(_data,_num,sizeof(_data))
#define Fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define O_(x) cout << #x << " " << x << "  ";
#define O(x) cout << #x << " " << x << endl;
using namespace std;
#define Mymax(a,b) if(a<b) a = b
#define Mymin(a,b) if(a>b) a = b
void Print(int _x){printf("%d\n",_x);}
void Print(ll _x){printf("%lld\n",_x);}
_tp<_tyn T>void Print( T _a[] , int _s , int _t ){
    for( int i = _s ; i <= _t ; i++ )
        cout << _a[i] << " ";
   	cout << endl;
}
#define il inline
#define rg register
struct InputReader{
    static const int bs = 100000;
    char buf[bs];
    int p;
    il InputReader():p(bs) {}
    il void Flush(){
        p = 0;
        fread(buf, 1, bs, stdin);
    }
    il char C(){
        if(p >= bs) Flush();
        return buf[p++];
    }
    int Getnum(){
        char ch = C();
        while( ch < '0'  ||  ch > '9' ) ch = C();
        return (int)(ch-'0');
    }
    il int operator() (){
        int ans = 0;
        char ch = C();
        int fu = 1;
        while( ch < '0'  ||  ch > '9' ){
            if( ch == '-' ) fu = -1;
            ch = C();
        }
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10;
            ans += ch-'0';
            ch = C();
        }
        return ans * fu;
    }
    ll Readll(){
        ll ans = 0LL;
        ll fu = 1;
        char ch = C();
        while( ch < '0'  ||  ch > '9' ){
            if( ch == '-' ) fu = -1;
            ch = C();
        }
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10LL;
            ans += ch-'0';
            ch = C();
        }
        return ans * fu;
    }
    il void Readstring( string &x ){
        x.clear();
        char ch = C();
        while( !isdigit(ch)  &&  !isalpha(ch) ) ch = C();
        while( isdigit(ch)  ||  isalpha(ch) ){
            x += ch;
            ch = C();
        }
    }
    il int Readchstr( char c[] ){
        int p = 0;
        char ch = C();
        while( !isdigit(ch)  &&  !isalpha(ch) ) ch = C();
        while( isdigit(ch)  ||  isalpha(ch) ){
            c[p] = ch;
            ch = C();
            p++;
        }
        c[p] = '\0';
        return p;
    }
    il void Readalpha( char &c ){
        c = C();
        while( !isalpha(c) ) c = C();
    }
    il void Specialread( char &c ){
        c = C();
        while( c != 'o'  &&  c != 'x'  &&  c != '?' ) c = C();
    }
}In;
il void Read( int &x ){ x = In(); }
il void Read( int &x, int &y ){ x = In(); y = In(); }
il void Read( int &x1 , int &x2 , int &x3 ){
    x1 = In(); x2 = In(); x3 = In();
}
il void Read( int &x1 , int &x2 , int &x3 , int &x4 ){
    x1 = In(); x2 = In(); x3 = In(); x4 = In();
}
il void Read( ll &x ){ x = In.Readll(); }
il void Read( ll &x, ll &y ){ x = In.Readll(); y = In.Readll(); }
il void Read( ll &x1 , ll &x2 , ll &x3 ){
    x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll();
}
il void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){
    x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); x4 = In.Readll();
}
clock_t _starttime , _endtime;
il void FILEIO(){
    #ifdef InterestingLSY
        _starttime = clock();
        Fin("in.in");
    #endif
}
#ifdef InterestingLSY
    #include <windows.h>
    #include <psapi.h>
#endif
il void END(){
    #ifdef InterestingLSY
        _endtime = clock();
        double _timeuse = (_endtime-_starttime)* 1000.0 / CLOCKS_PER_SEC;
        printf("\n\nTime usage:\n%.0lf ms\n",_timeuse);
        HANDLE _handle = GetCurrentProcess();
        PROCESS_MEMORY_COUNTERS pmc;
        GetProcessMemoryInfo(_handle,&pmc,sizeof(pmc));
        double _memuse = pmc.PeakPagefileUsage/1024.00/1024.00;
        printf("Memory usage:\n%.1lf MB\n\n",_memuse);
    #endif
    exit(0);
}
#define For(i,j) for( rg int (i) = 1 ; (i) <= (j) ; (i)++ )
#define For0(i,j) for( rg int (i) = 0 ; (i) < (j) ; (i)++ )
#define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; (i)++ )
#define Forstep(i,j,k,st) for( rg int (i) = (j) ; (i) <= (k) ; (i) += (st) )
#define fOR(i,j) for( rg int (i) = (j) ; (i) >= 1 ; (i)-- )
#define fOR0(i,j) for( rg int (i) = (j)-1 ; (i) >= 0 ; (i)-- )
#define fORx(i,j,k) for( rg int (i) = (k) ; (i) >= (j) ; (i)-- )
int dx[] = {0,-1,0,1};
int dy[] = {1,0,-1,0};
//			D L U  R
#define Mymod(a,b) if( a >= b ) a -= b;
#define Rmod(a,b) a = (a%b+b)%b
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
#define MOD 998244353
#define MAXN 300010

int n;
ll A,B,k;
ll ans = 0;

ll frac[MAXN];
ll inv[MAXN];
void Calfrac(){
	frac[0] = 1;
	For(i,MAXN-1)
		frac[i] = frac[i-1]*i%MOD;
}
ll Pow( ll a , ll b ){
	ll ret = 1;
	while(b){
		if(b&1){
			ret = ret*a%MOD;
		}
		a = a*a%MOD;
		b >>= 1;
	}
	return ret;
}
ll Inv( ll a ){
	return Pow(a,MOD-2);
}
void Calinv(){
	inv[0] = 1;
	inv[1] = 1;
	Forx(i,2,MAXN-1)
		inv[i] = Inv(frac[i]);
}

ll C( ll b , ll a ){
	if( b > a ) return 0;
	ll ret = frac[a];
	ret = ret * inv[b] % MOD;
	ret = ret * inv[a-b] % MOD;
	if(!ret) ret = 1;
	return ret;
}

ll Solve( ll a , ll b ){
	ll ret = 0;
	Forx(c,max(a+b-n,0),min(a,b)){
		if( a+b-c > n ) continue;
		//cout << a-c << " " << c << " " << b-c << endl;
		ll tret = frac[n];
		tret = tret * inv[a-c] % MOD;
		tret = tret * inv[b-c] % MOD;
		tret = tret * inv[c] % MOD;
		tret = tret * inv[n-a-b+c] % MOD;
		ret += tret;
		ret %= MOD;
	}
	return ret;
}

int main(){
	FILEIO();
	Calfrac();
	Calinv();

	Read(n);
	Read(A,B,k);

	Forx(a,0,n){
		ll left = k-(ll)a*A;
		if( left < 0 ) break;
		if( left % B ) continue;
		int b = left/B;
		if( b > n ) continue;
		ans += Solve(a,b);
	}
	printf("%lld\n",ans);

	END();
}


Compiler output:
a.cc: In function 'void Calfrac()':
a.cc:183:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  183 |         For(i,MAXN-1)
      |             ^
a.cc:158:31: note: in definition of macro 'For'
  158 | #define For(i,j) for( rg int (i) = 1 ; (i) <= (j) ; (i)++ )
      |                               ^
a.cc: In function 'void Calinv()':
a.cc:203:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  203 |         Forx(i,2,MAXN-1)
      |              ^
a.cc:160:34: note: in definition of macro 'Forx'
  160 | #define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; (i)++ )
      |                                  ^
a.cc: In function 'long long int Solve(long long int, long long int)':
a.cc:218:19: error: no matching function for call to 'max(long long int, int)'
  218 |         Forx(c,max(a+b-n,0),min(a,b)){
      |                ~~~^~~~~~~~~
a.cc:160:40: note: in definition of macro 'Forx'
  160 | #define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; (i)++ )
      |                                        ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:218:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  218 |         Forx(c,max(a+b-n,0),min(a,b)){
      |                ~~~^~~~~~~~~
a.cc:160:40: note: in definition of macro 'Forx'
  160 | #define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; (i)++ )
      |                                        ^
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:218:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  218 |         Forx(c,max(a+b-n,0),min(a,b)){
      |                ~~~^~~~~~~~~
a.cc:160:40: note: in definition of macro 'Forx'
  160 | #define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; (i)++ )
      |                                        ^
a.cc:218:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  218 |         Forx(c,max(a+b-n,0),min(a,b)){
      |              ^
a.cc:160:34: note: in definition of macro 'Forx'
  160 | #define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; (i)++ )
      |                                  ^
a.cc: In function 'int main()':
a.cc:240:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  240 |         Forx(a,0,n){
      |              ^
a.cc:160:34: note: in definition of macro 'Forx'
  160 | #define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; (i)++ )
      |                                  ^