問題一覧 > 通常問題

No.1513 simple Kadomatsu Sequence problem

レベル : / AI推定難易度 : 1750 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 76
作問者 : ansain / テスター : akakimidori
お気に入りにしたユーザー ProblemId : 6257 / 自分の提出
問題文最終更新日: 2021-05-19 03:08:19
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. Back to the original
yukicoder contest 296 (順位表) の他の問題:

From the Problem Writer

・This problem differs from Problem F only in the constraints and the execution time limit.
・AC has been confirmed with python and pypy, but in slow languages, it may not finish in time depending on the implementation.

Problem Statement

When a sequence $v=(a_1,a_2,a_3)$ consisting of 3 elements satisfies the following conditions, it is said by tradition that $v$ is a Kadomatsu sequence.
1.$a_1,a_2,a_3$ are all distinct
2.Among the 3 elements, $a_2$ is the largest or the smallest
Furthermore, for a sequence $ w=(a_1,a_2....,a_n)$ consisting of $n$ elements (where $3≦n$),
if any 3 consecutive elements taken from it form a Kadomatsu sequence, then $w$ is called a Kadomatsu sequence sequence.

There are $K^N$ integer sequences of length $N$ in which each element is at least $0$ and less than $K$. Suppose that $ans_1$ of them are Kadomatsu sequence sequences. Output $ans_1$ modulo $998244353$.
Furthermore, for each of the $ans_1$ Kadomatsu sequence sequences, calculate the sum of the sequence, and let $ans_2$ be the total of these sums. Output $ans_2$ modulo $998244353$.

Input

$N\ K$

$3≦N,K≦200$
$N,K$ are integers.

Output

Output $ans_1$ and $ans_2$, each modulo $998244353$, separated by a single-byte space.
Print a newline at the end.

Sample

Sample 1
Input
3 3
Output
4 12

$(0,2,1)$
$(1,2,0)$
$(1,0,2)$
$(2,0,1)$
There are these $4$ sequences, and the total of their sums is $12$.

Sample 2
Input
6 9
Output
26124 626976

Sample 3
Input
200 200
Output
121468035 464317887

Output the values modulo $998244353$.

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