QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#912. 対角線

Estadísticas

小艾は小蘭に問題を一つ出しました。$n \times n$ のマス目があり、各マスに $1$ から $c$ までの整数を一つずつ置きます。どの行にも少なくとも2種類の数字が含まれ、かつどの列にも少なくとも2種類の数字が含まれるような置き方は何通りあるでしょうか。

数え上げを学んだばかりの小蘭は、すぐにこの問題を解いてしまいました。

そこで小艾は難易度を上げました。もし $i=j$ となる対角線上の数字がすべて $1$ でなければならない場合、置き方は何通りになるでしょうか。

小蘭のために計算してください。答えは $998244353$ で割った余りを求めてください。

入力

一行に二つの正整数 $n, c$ が与えられます。

出力

条件を満たす置き方の数を $998244353$ で割った余りを出力してください。

入出力例

入力 1

2 3

出力 1

4

入力 2

3 3

出力 2

416

入力 3

5 2

出力 3

592260

小課題

$100\%$ のデータにおいて、$2 \le n \le 10^6, 2 \le c \le 10^8$ を満たします。

データ点 $1,2$ $3$ $4$ $5$ $6$ $7$ $8$ $9$ $10$
$n=$ $2$ $5$ $50$ $200$ $500$ $2000$ $5000$ $10^5$ $10^6$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.