Public Judge

pjudge

時間限制: 2 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#21656. [PR #5] Cyclic Shift

统计

Here is a very simple problem: given a permutation $p$ of $1 \sim n$, find its unique cyclic shift that starts with $1$.

Little T wrote the following code:

// input p

for (int i=2;i<=n;i++)
    if (p[i]<p[1])
        shift(i); // change p to p[i],p[i+1],...,p[n],p[1],...,p[i-1]

// output p

Given a positive integer $n$, find how many different permutations $p$ will cause the algorithm above to output an incorrect result. Note that the answer does not need to be taken modulo any number.

Input

The first line contains a positive integer $n$.

Output

The first line contains a positive integer $ans$, representing the answer.

Examples

Input 1

3

Output 1

1

Note

The only permutation that causes it to output an incorrect answer is 3,2,1, which results in 2,1,3.

Input 2

7

Output 2

1023

For all test cases, $3\le n\le 42$. Within each group of test cases, $n$ is approximately uniformly distributed.

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.