Tap here to switch tabs
Problem
Submissions

Problem: Paint Fence

Try to solve the Paint Fence problem.

Statement

You are given a fence with n posts and k different colors. Determine the total number of valid ways to paint the fence such that no more than 22 consecutive posts share the same color.

Constraints:

  • 1≤1 \leq n ≤50\leq 50

  • 1≤1 \leq k ≤105\leq 10^5

  • The test cases are generated such that the answer is within the range [0,231−1][0, 2^{31} - 1] for the given n and k.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Paint Fence

Try to solve the Paint Fence problem.

Statement

You are given a fence with n posts and k different colors. Determine the total number of valid ways to paint the fence such that no more than 22 consecutive posts share the same color.

Constraints:

  • 1≤1 \leq n ≤50\leq 50

  • 1≤1 \leq k ≤105\leq 10^5

  • The test cases are generated such that the answer is within the range [0,231−1][0, 2^{31} - 1] for the given n and k.