String Splitting
InterviewTime limit1sMemory limit512 MB
Count the ways to cut a digit string into K nonempty contiguous pieces so that no piece starts with a 0 (the piece "0" alone is allowed).
- Level
Medium6 of 10
- Topics
- Dynamic programming, String, Combinatorics, Prefix sum
- Solved
- No attempts yet
Problem
You are given a string consisting of digits. Split by cutting it times into nonempty contiguous substrings. Count the number of ways to split such that no contiguous substring has a leading zero.
Input
The first line gives the length of the string and the number of contiguous substrings . ()
The second line gives the string .
Output
Print the number of ways modulo on the first line.
Hint
A leading zero is any digit 0 that comes before the first nonzero digit in a string of digits.
The string "0" does not have a leading zero.