No.1513 simple Kadomatsu Sequence problem
タグ : / 解いたユーザー数 76
作問者 :
ansain
/ テスター :
akakimidori
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もしくは右上の雲マークをクリックしてアカウントを作成してください。