#K78462. Unique K-Length Strings Without Adjacent Duplicate Characters

    ID: 35092 Type: Default 1000ms 256MiB

Unique K-Length Strings Without Adjacent Duplicate Characters

Unique K-Length Strings Without Adjacent Duplicate Characters

You are given an integer K which represents the length of strings to be formed using the 4 characters {a, b, c, d}. Your task is to compute the number of unique K-length strings such that no two adjacent characters are the same.

The answer can be derived using the formula:

\(4 \times 3^{K-1}\) for \(K \geq 1\).

For example:

  • When K = 1, the number of strings is 4.
  • When K = 2, the number of strings is 12.
  • When K = 3, the number of strings is 36.

Write a program that reads the integer K from standard input and outputs the number of valid strings to standard output.

inputFormat

The input consists of a single integer K (where K ≥ 1) provided through standard input.

outputFormat

Output a single integer representing the number of unique K-length strings that can be formed under the given conditions.

## sample
1
4

</p>