Problem:
Score : 700 points

Problem Statement

Takahashi has a tower which is divided into N layers.
Initially, all the layers are uncolored. Takahashi is going to paint some of the layers in red, green or blue to make a beautiful tower.
He defines the beauty of the tower as follows:

The beauty of the tower is the sum of the scores of the N layers, where the score of a layer is A if the layer is painted red, A+B if the layer is painted green, B if the layer is painted blue, and 0 if the layer is uncolored.

Here, A and B are positive integer constants given beforehand. Also note that a layer may not be painted in two or more colors.

Takahashi is planning to paint the tower so that the beauty of the tower becomes exactly K.
How many such ways are there to paint the tower? Find the count modulo 998244353.
Two ways to paint the tower are considered different when there exists a layer that is painted in different colors, or a layer that is painted in some color in one of the ways and not in the other.

Constraints

1 ≤ N ≤ 3×10^5

1 ≤ A,B ≤ 3×10^5

0 ≤ K ≤ 18×10^{10}

All values in the input are integers.

Input

Input is given from Standard Input in the following format:

N A B K

Output

Print the number of the ways to paint tiles, modulo 998244353.

Sample Input 1

4 1 2 5

Sample Output 1

40

In this case, a red layer worth 1 points, a green layer worth 3 points and the blue layer worth 2 points. The beauty of the tower is 5 when we have one of the following sets of painted layers:

1 green, 1 blue

1 red, 2 blues

2 reds, 1 green

3 reds, 1 blue

The total number of the ways to produce them is 40.

Sample Input 2

2 5 6 0

Sample Output 2

1

The beauty of the tower is 0 only when all the layers are uncolored. Thus, the answer is 1.

Sample Input 3

90081 33447 90629 6391049189

Sample Output 3

577742975

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

/*
Я засыпаю в темноте, и страшно мне открыть глаза
Я засыпаю в темноте - и помню все, что сделал сам
Я засыпаю в темноте, не добрых мыслей жуткий рой
Я засыпаю в темноте, а завтра - я проснусь другой
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;

const double EPS = 1e-5;
const int mod = 1e9 + 7;
const int fft_mod = 998244353;
const ll INFLL = 1e18;
const int INF = 1e9;
const int maxn = 1e5 + 3;

ll gcd(ll a, ll b){
    if (b == 0ll)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return (a / gcd(a, b) )* b;
}

bool is_prime(ll a){
    if (a == 2 || a == 3 || a == 5 || a == 7) return true;
    if (a % 2 == 0 || a%3 == 0 || a%5 == 0 || a%7 == 0)
        return false;
    for (ll i = 11; i * i <= a; i += 2){
        if (a % i == 0)
            return false;
    }
    return true;
}

ll binpow(ll a, int n){
    if (n == 0)
        return 1;
    if (n % 2 == 0){
        ll q = binpow(a, n / 2);
        return (q * q) % fft_mod;
    }else return (a * binpow(a, n - 1) ) % fft_mod;
}

istream& operator>>(istream &in, pair<int, int> &p) {
    in >> p.fi >> p.se;
    return in;
}

ostream& operator<<(ostream &out, pair<int, int> &p) {
    out << p.fi << " " << p.se << endl;
    return out;
}



















main(){
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    if (k == 0){
        cout << 1;
        return 0;
    }
    ll fact[n + 1];
    fact[0] = 1;
    ll obr_fact[n + 1];
    obr_fact[0] = 1;
    for (ll i = 1; i <= n; i++){
        fact[i] = (fact[i - 1] * i) % fft_mod;
        obr_fact[i] = binpow(fact[i], fft_mod - 2);
    }
    ll ans = 0;
    for (ll j = 0; j <= n; j++){
        ll flex = j * a;
        ll req = k - flex;
        if (req < 0) break;
        if (req % b != 0 || req/b > n) continue;
        ll fle = req/b;
        ans = (ans + (((fact[n] * ( (obr_fact[j] * obr_fact[n - j]) % fft_mod) ) % fft_mod )*( (fact[n] * ( (obr_fact[fle] * obr_fact[n - fle]) % fft_mod)) % fft_mod))%fft_mod )% fft_mod;
    }
    cout << ans;

}