FILRTEST - File Recover Testing
In a recent programming contest appeared a problem named “File Recover”. In that problem, repeated strings of a given text were to be counted. You are preparing test cases for that problem, and in order to test for border cases you want to generate a text with many repetitions of a particular string. Of course, test cases cannot be arbitrarily long, so you decided to choose a length and a string, and then fit in a text of that length as many repetitions as possible of the string.
For instance, if the length is 14 and the string is “abcab”, you may generate the text “abcabcabcabcab” whose length is 14 and where the string “abcab” appears 4 times (starting at positions 1, 4, 7 and 10).
You would like to know how good your idea is before implementing. Given a length and a string, you must determine the maximum number of times the characters of the string can appear consecutively in a text of that length.
Input
Each test case is described using a single line. The line contains an integer K (1 ≤ K ≤ 109 ) and a non-empty string S of at most 106 lowercase letters. The end of input is indicated with a line containing the number −1 and an asterisk (“*”).
Output
For each test case, output a single line with a single integer representing the maximum number of times the characters of S can appear consecutively in a text of length K.
Example
Input: 14 abcab 1000 abcde 1000000000 z 1 zzzzz -1 * Output: 4 200 1000000000 0
hide comments
Pablo Ariel Heiber:
2010-09-27 23:27:20
File Recover is a problem of 2009 latin american regional: http://acm.uva.es/archive/nuevoportal/region.php?r=sa&year=2009 |
Added by: | Pablo Ariel Heiber |
Date: | 2010-09-27 |
Time limit: | 1.975s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 NODEJS OBJC VB.NET |
Resource: | FCEyN UBA ICPC Selection 2010 |