Make a Periodic String
Time limit2sMemory limit128 MB
Given a DNA string and a bound M, find the minimum number of character edits to make the string periodic with some period length at most M.
- Level
Medium5 of 10
- Topics
- String, Greedy, Brute force, Implementation
- Solved
- No attempts yet
Problem
Sejun is a biologist, so he often works with DNA strings. One day, he became tired of looking at a long DNA string and wanted to express it in a simpler periodic form.
For a string of length , a positive integer is a period length if, for every integer with , the character at position is the same as the character at position . For example, CATCATC, CATCAT, ACTAC, and ACT all have period length .
Given a DNA string, change as few characters as possible so that it becomes a periodic string whose period length is at most . Find the minimum number of characters that must be changed.
Input
The first line contains . The value of is at most the length of the string.
The second line contains the DNA string. The string consists only of A, C, G, and T, and its length is at most .
Output
Print the minimum number of characters that must be changed.