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

21913번 - Modulo Permutations 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB129595547.414%

문제

Given a natural number $n,ドル count the number of permutations $(p_1, p_2, \dots , p_n)$ of the numbers from 1ドル$ to $n,ドル such that for each $i$ (1ドル \le i \le n$), the following property holds: $p_i \bmod p_{i+1} \le 2,ドル where $p_{n+1} = p_1$.

As this number can be very big, output it modulo 10ドル^9 + 7$.

입력

The only line of the input contains the integer $n$ (1ドル \le n \le 10^6$).

출력

Output a single integer — the number of the permutations satisfying the condition from the statement, modulo 10ドル^9 + 7$.

제한

예제 입력 1

1

예제 출력 1

1

예제 입력 2

2

예제 출력 2

2

예제 입력 3

3

예제 출력 3

6

예제 입력 4

4

예제 출력 4

16

예제 입력 5

5

예제 출력 5

40

예제 입력 6

1000000

예제 출력 6

581177467

힌트

For example, for $n = 4$ you should count the permutation $[4, 2, 3, 1],ドル as 4ドル \bmod 2 = 0 \le 2,ドル 2ドル \bmod 3 = 2 \le 2,ドル 3ドル \bmod 1 = 0 \le 2,ドル 1ドル \bmod 4 = 1 \le 2$. However, you shouldn’t count the permutation $[3, 4, 1, 2],ドル as 3ドル \bmod 4 = 3 > 2$ which violates the condition from the statement.

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2020 I번

Contest > Open Cup > 2020/2021 Season > Stage 17: Grand Prix of Southern Europe I번

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

출처

대학교 대회

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

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