Logo
(追記) (追記ここまで)

24693번 - Implemented Incorrectly 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB966100.000%

문제

Consider the following problem:

  • You are given a permutation $A = \langle a_1, a_2, \ldots, a_n \rangle$ containing each integer from 1ドル$ to $n$ exactly once. Find its only cyclic shift that starts with 1ドル$.

Consider the following algorithm to solve it:

  • Input: $A = \langle a_1, a_2, \ldots, a_n \rangle$.
  • For each $i = 2, 3, \ldots, n$:
    • if $a_i < a_1$:
      • rotate $A$ to move $a_i$ to the front; that is, set $A \leftarrow \langle a_i, a_{i+1}, \ldots, a_n, a_1, a_2, \ldots, a_{i-1} \rangle$.
  • Output: $A = \langle a_1, a_2, \ldots, a_n \rangle$.

You are given a single integer $n$. Find the number of permutations on which the described algorithm solves the problem incorrectly.

입력

The only line contains a single integer $n$ (1ドル \le n \le 42$).

출력

Print the number of permutations on which the described algorithm works incorrectly.

제한

예제 입력 1

3

예제 출력 1

1

예제 입력 2

7

예제 출력 2

1023

힌트

In the first example test case, for $n = 3,ドル the only permutation resulting in an incorrect output is $\langle 3, 2, 1 \rangle$. The algorithm returns $\langle 2, 1, 3 \rangle,ドル while the correct answer is $\langle 1, 3, 2 \rangle$.

출처

Camp > Petrozavodsk Programming Camp > Winter 2022 > Day 7: ICPC Camp Day 2, Gennady Korotkevich Contest 6 I번

Contest > Open Cup > 2021/2022 Season > Stage 13: Grand Prix of Gomel I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /