問題一覧 > 通常問題

No.1403 調和の魔法陣

レベル : / 実行時間制限 : 1ケース 3.153秒 / メモリ制限 : 315 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 4
作問者 : CuriousFairy315 / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 4596 / 自分の提出
問題文最終更新日: 2022-11-25 21:24:00
Magic Circle of Harmony
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder contest 283 (順位表) の他の問題:

Problem Statement

315-san is studying magic circles.
Magic circles come in various shapes, such as pentagrams, hexagrams, and circular formations, and they take effect when catalysts of appropriate strength are placed on them.
The magic circle to be drawn this time is a rectangle divided into $H$ parts vertically and $W$ parts horizontally, and it takes effect by placing catalysts on its cells.
However, if a magic circle does not maintain harmony, the propagation of magical power becomes uneven, and the spell eventually breaks down.
The magic circle drawn this time is said to maintain harmony when, for every cell, the sum $S$ of the strengths of the catalysts in the $3 \times 3$ cell range centered on that cell is the same.
That is, letting $M_{y, x}$ be the strength of the catalyst in cell $(x, y)$, it must hold that $\sum_{i=y-1}^{y+1} \sum_{j=x-1}^{x+1} M_{i, j} = S$ for all integers $x, y$ satisfying $1 \leq x \leq W, 1 \leq y \leq H$.
In this case, the strength of the magic circle is $S$.
315-san has many catalysts of strengths between $1$ and $9$, inclusive, and wants to create a magic circle of strength $X$ that maintains harmony by placing these catalysts appropriately.
At most 1 catalyst can be placed on each cell (it is also possible to place none), so $0 \leq M_{y, x} \leq 9$ for all integers $x, y$ satisfying $1 \leq x \leq W, 1 \leq y \leq H$, and $M_{y, x} = 0$ for all other $x, y$.
There are $10^{WH}$ ways in total to place catalysts on the magic circle; among them, what placements make the magic circle maintain harmony?
There are $T$ test cases in total.
For each test case, $W_i, H_i, X_i$ are given; find the number of magic circles of strength $X_i$ that maintain harmony.
Since the answer can be very large, output the answer modulo $998244353$ (a prime).

Input

$T$
$W_1\ H_1\ X_1$
$\vdots$
$W_T\ H_T\ X_T$

  • $1 \leq T \leq 10000$
  • $1 \leq W_i, H_i \leq 600$
  • $0 \leq X_i \leq 81$
  • All inputs are integers

Output

On line $i$, find the number of magic circles that maintain harmony with height $H_i$, width $W_i$, and strength $X_i$, and output the answer modulo $998244353(= 119 \times 2^{23} + 1)$.
Print a newline at the end.

Sample

Sample 1
Input
1
2 2 6
Output
84

The answer is $_{4}H_{6}=_{4+6-1}C_{6}=84$ ways.

Sample 2
Input
1
5 2 4
Output
259

Sample 3
Input
1
3 3 81
Output
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。