問題一覧 > 通常問題

No.411 Ascending Ascending Sort

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 224
作問者 : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 754 / 自分の提出
問題文最終更新日: 2026-06-25 05:41:52
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 146 (順位表) の他の問題:

Problem Statement

Ascending sort rearranges the numbers of an array into an ascending array, ordered from smallest to largest.

Now, A-kun has come up with something called ascending ascending sort.
Ascending ascending sort rearranges an array so that, among adjacent elements $ A_i, A_{i+1} $, there exists exactly one $i$ such that $A_i > A_{i+1}$.

The result of ascending sort is unique, but the result of ascending ascending sort is not necessarily unique.
You are given the numbers from 1 to $N$, one of each. Count the candidates among the results of ascending ascending sort whose first element of the array is $K$.

Input

N K

A positive integer N is given. $2 \le N \le 20$.
A positive integer K is given. $1 \le K \le N$.

Output

Output the answer on one line. Do not forget the newline at the end.

Sample

Sample 1
Input
2 2
Output
1

Ascending sort gives the result [1,2].
Ascending ascending sort gives the result [2,1].
The first number of [2,1], obtained by ascending ascending sort, is 2, so the answer is 1 way.

Sample 2
Input
3 2
Output
2

Ascending sort gives the result [1,2,3].
Ascending ascending sort gives one of [1,3,2], [2,1,3], [2,3,1], [3,1,2].
Among these, the candidates starting with 2 are [2,1,3] and [2,3,1], which is 2 ways.

Sample 3
Input
5 3
Output
4

Sample 4
Input
2 1
Output
0

Among the results of ascending ascending sort, none starts with 1.

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