#include #include #include #include #include #include using namespace std; const double pi = acos(-1.0); const int maxn = 1 << 18; const int mo=119; struct Complex { double x, y; Complex (double real = 0, double imag = 0) : x(real), y(imag) {} double &real() { return x; } double &imag() { return y; } void print() { cout<<"real="<>= 1, ~j & s;); if (i < j) { swap(P[i], P[j]); } } Complex unit_p0; for (int d = 0; (1 << d) < n; d++) { int m = 1 << d, m2 = m * 2; double p0 = pi / m * oper; sincos(p0, unit_p0.y, unit_p0.x); for (int i = 0; i < n; i += m2) { Complex unit = 1; for (int j = 0; j < m; j++) { Complex &P1 = P[i + j + m], &P2 = P[i + j]; Complex t = unit * P1; P1 = P2 - t; P2 = P2 + t; unit = unit * unit_p0; } } } } struct poly{ int u[50000]; poly() { memset(u,0,sizeof(u)); } poly operator *(poly &B) { poly c; for (int i=0;i=q;i--) if (c.u[i]) (c.u[i-p]+=(c.u[i]*a)%mo)%=mo, (c.u[i-q]+=(c.u[i]*b)%mo)%=mo; return c; } void print() { for (int i=0;i>=1) { if (e&1) sum=sum*b; b=b*b; } } int main() { for (;cin>>n>>a>>b>>p>>q;) { a%=mo,b%=mo; for (int i=1;i<=2*q;i++) f[i]=(a*func(i-p)+b*func(i-q))%mo; if (n<=2*q) { printf("%d\n",f[n]); continue; } for (N=1;N<=q+q+1;N<<=1) ; poly A,B; fgm(n-q,A,B); int ans=0; for (int i=q-1;i>=0;i--) ans=(ans+A.u[i]*f[i+q])%mo; printf("%d\n",ans); } return 0; }