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

19408번 - Highly Composite Permutations 스페셜 저지다국어

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

문제

Positive integer $x$ is called composite if it has strictly more than two positive integer divisors. For example, integers 4, 30 and 111 are composite, while 1, 7 and 239 are not.

Integer sequence $p = \langle p_1, p_2, \ldots, p_n \rangle$ is called a permutation of length $n$ if it contains every integer between 1 and $n,ドル inclusive, exactly once.

We'll call permutation $p = \langle p_1, p_2, \ldots, p_n \rangle$ highly composite if for every $i$ between 1 and $n,ドル inclusive, the sum of the first $i$ elements of $p$ (that is, $p_1 + p_2 + \ldots + p_i$) is composite.

Given a single integer $n,ドル find a highly composite permutation of length $n$.

입력

The only line of the input contains a single integer $n$ (1ドル \le n \le 100$).

출력

If no highly composite permutation of length $n$ exists, output a single integer $-1$. Otherwise, output $n$ integers $p_1, p_2, \ldots, p_n$ such that $p = \langle p_1, p_2, \ldots, p_n \rangle$ is a highly composite permutation.

If there are multiple highly composite permutations of length $n,ドル you may output any of them.

제한

예제 입력 1

13

예제 출력 1

9 13 6 5 3 2 8 4 1 12 11 10 7

예제 입력 2

2

예제 출력 2

-1

힌트

In the first example test case, the first element of the permutation, 9, is composite, the sum of the first two elements of the permutation, 9ドル + 13 = 22,ドル is composite, the sum of the first three elements of the permutation, 9ドル + 13 + 6 = 28,ドル is composite, and so on.

In the second example test case, only two permutations of the required length exist, $\langle 1, 2 \rangle$ and $\langle 2, 1 \rangle,ドル and neither of them is highly composite.

출처

Camp > Petrozavodsk Programming Camp > Winter 2017 > Day 6: Gennady Korotkevich Contest 2, Head of Republic of Karelia Cup, Round II H번

Contest > Open Cup > 2016/2017 Season > Stage 10: Grand Prix of Gomel H번

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

출처

대학교 대회

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

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