QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#912. 对角线

統計

小艾给小兰出了一道题:一个 $n\times n$ 的方格,每个格子放一个 $1\sim c$ 的整数,有多少种方案使得任何一行有至少两种数出现,任何一列至少有两种数出现?

刚学过数数的小兰随便推了推,就解决了这个问题。

于是小艾加大了难度:如果 $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$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.