#K86542. Repeated Substring Verification

    ID: 36887 Type: Default 1000ms 256MiB

Repeated Substring Verification

Repeated Substring Verification

Given a string s and an integer k, determine whether the string s can be constructed by repeating its first k characters several times.

In other words, the problem asks whether there exists a substring t of length k such that \[ s = \underbrace{t \; t \; \cdots \; t}_{n}\n\] where \( n = \frac{|s|}{k} \) and \(|s|\) is the length of s. Note that if \(|s|\) is not divisible by \(k\), the answer is automatically False.

The challenge involves simple string operations and checks for divisibility and equality.

inputFormat

The input is given via stdin and consists of two lines:

  • The first line contains a non-empty string s.
  • The second line contains an integer k.

outputFormat

Output a single line to stdout containing True if s can be formed by repeating its first k characters, or False otherwise.

## sample
ababab
2
True