Tap here to switch tabs
Problem
Submissions

Problem: Count Ways to Distribute Candies

Count Ways to Distribute Candies asks you to place distinct, labeled candies into identical bags. Return the number of ways to place every candy so each bag is nonempty, modulo a large prime.

Statement

You are given nn distinct candies labeled from 11 to n and kk identical bags.

You need to distribute all n candies into the k bags such that each bag contains at least 11 candy.

Return the total number of ways to distribute the candies. Since the answer may be large, return it modulo 109+710^9 + 7.

Note: Bags are identical, so the order of the bags does not matter. Two distributions are considered different if there exist two candies that are in the same bag in one distribution but in different bags in the other distribution.

Constraints:

  • 1≤1 \leq k ≤\leq n ≤1000\leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Ways to Distribute Candies

Count Ways to Distribute Candies asks you to place distinct, labeled candies into identical bags. Return the number of ways to place every candy so each bag is nonempty, modulo a large prime.

Statement

You are given nn distinct candies labeled from 11 to n and kk identical bags.

You need to distribute all n candies into the k bags such that each bag contains at least 11 candy.

Return the total number of ways to distribute the candies. Since the answer may be large, return it modulo 109+710^9 + 7.

Note: Bags are identical, so the order of the bags does not matter. Two distributions are considered different if there exist two candies that are in the same bag in one distribution but in different bags in the other distribution.

Constraints:

  • 1≤1 \leq k ≤\leq n ≤1000\leq 1000