F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Easy Math Problem

Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 439    Accepted Submission(s): 73


Problem Description
You need to calculate $\sum\limits_{i=1}^n\sum\limits_{j=1}^n{\tbinom{i + j}{i} \cdot f(i + j, i)}$, where $f(0, x) = 0, f(1, x) = a,$ and for all $2 \leq m \leq x$, $f(m, x) = b \cdot f(m - 1, x) + c \cdot f(m - 2, x)$, and moreover, for all $m > x$, $f(m, x) = d \cdot f(m - 1, x) + e \cdot f(m - 2, x)$.

In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is indexed by a pair of integers $n \geq k \geq 0$ and is written $\tbinom {n}{k}$. It is the coefficient of the $x^k$ term in the polynomial expansion of the binomial power $(1 + x)^n$, and is given by the formula

$$\binom{n}{k} = \frac{n!}{k!(n-k)!}$$
 

Input
This problem contains multiple test cases.

The first line contains an integer $T(1 \leq T \leq 50)$ indicating the number of test cases.

The next $T$ lines each contains six integers $n, a, b, c, d, e(1 \leq n \leq 10 ^ 5, 1 \leq a, b, c, d, e \leq 10 ^ 6)$.
 

Output
Output $T$ lines, each line contains an integer indicating the answer.

Since the answer can be very large, you only need to output the answer modulo $998244353$.
 

Sample Input
2 3 1 1 1 1 1 2 1 2 3 4 5
 

Sample Output
316 482
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-27 07:13:25, Gzip enabled