RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 COCI00711

Festival

설명

While Ivan was working at this year’s chocolate festival, his boss gave him \(n\)
different chocolate candies and asked him to prepare \(k\) chocolate boxes using those
candies. Before he starts arranging the boxes, Ivan wants to find out in how many
different ways he can arrange them, and then, after considering all the possibilities,
he will choose the best arrangement.
The chocolate festival is a very important and serious event, so the candies must be
perfectly arranged. To achieve this, Ivan knows that he must follow the following
rules:
• Each box must contain at least one candy.
• Each candy goes in exactly one box.
• The boxes he uses are identical to each other, so swapping the contents of
two boxes does not create a new arrangement. All that matters is which
candies are in which box and in what order they are arranged.
• The largest candy is always the first in the box. We can assume that in any
group of candies, the largest can always be uniquely determined.
In how many different ways can Ivan arrange the boxes? Since the number of ways can be very large,
print it modulo \(10^{9} + 7\).

제약
입력 형식

The first and only line contains the natural numbers \(n\) and \(k\) (\(1 \le n \le 5000\), \(1 \le k \le n\)), the number of
candies, and the number of boxes.

출력 형식

In the first and only line, print a single number - the number of ways Ivan can arrange the boxes modulo
\(10^{9} + 7\).

서브태스크
서브태스크점수설명

1

8점

\(k = 1\)

2

19점

\(k = 2\)

3

14점

\(n \le 10\)

4

29점

No additional constraints.

예제 1
입력
3 1
출력
2
예제 2
입력
3 2
출력
3
예제 3
입력
4 2
출력
11
설명

Clarification of the first example:
Let’s label the candies from smallest to largest with 1, 2, and 3. We need to arrange them in one box,
so all three candies must be in the same box. Candy 3 must be first because it is the largest. We can
arrange the other two candies in two ways, so [3, 1, 2] and [3, 2, 1] are the only valid arrangements.
Clarification of the second example:
Let’s label the candies from smallest to largest with 1, 2, and 3. We can arrange the candies in three
ways: {[1], [3, 2]}, {[2], [3, 1]}, and {[3], [2, 1]}.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2025/2026 Contest 3

평가 및 의견

Festival

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Festival

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8