Calculate with f(i, j, k)

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 0.5s
Giới hạn bộ nhớ: 1004M
Input: stdin
Output: stdout

Nguồn bài:
Vũ Huy Trường :))
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Define the function ~f(i, j, k)~ recursively as follows:

Function f(i, j, k):
    if i = 0 and j = 0 and k = 0:
        return 1
    ans <- 0
    for x = 0 to i:
        for y = 0 to j:
            for z = 0 to k:
                if x = i and y = j and z = k:
                    continue
                ans <- ans + f(i-x, j-y, k-z) + f(x, y, z)
    return ans mod 998244353

You are given ~Q~ queries. Each query contains three non-negative integers ~i~, ~j~, and ~k~.

For each query, compute and output the value of ~f(i, j, k)~ modulo ~998244353~.

Input

The first line contains an integer ~Q~ — the number of queries.

Each of the next ~Q~ lines contains three integers ~i~, ~j~, and ~k~ describing one query.

Output

For each query, print one integer — the value of ~f(i, j, k)~ modulo ~998244353~.

Constraints
  • ~1 \le Q \le 100~
  • ~0 \le i, j, k \le 10^{5}~
Sample Input
3
1 2 3
4 5 6
7 8 9
Sample Output
7209
939856628
210934339

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.