612A.md (1581B)
1 Source: https://codeforces.com/problemset/problem/612/A 2 3 A. The Text Splitting 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given the string *s* of length *n* and the numbers *p*, *q*. Split the string *s* to pieces of length *p* and *q*. 22 23 For example, the string "Hello" for *p* = 2, *q* = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo". 24 25 Note it is allowed to split the string *s* to the strings only of length *p* or to the strings only of length *q* (see the second sample test). 26 27 Input 28 29 The first line contains three positive integers *n*, *p*, *q* (1 ≤ *p*, *q* ≤ *n* ≤ 100). 30 31 The second line contains the string *s* consists of lowercase and uppercase latin letters and digits. 32 33 Output 34 35 If it's impossible to split the string *s* to the strings of length *p* and *q* print the only number "-1". 36 37 Otherwise in the first line print integer *k* — the number of strings in partition of *s*. 38 39 Each of the next *k* lines should contain the strings in partition. Each string should be of the length *p* or *q*. The string should be in order of their appearing in string *s* — from left to right. 40 41 If there are several solutions print any of them. 42 43 Examples 44 45 Input 46 47 ``` 48 5 2 3 49 Hello 50 ``` 51 52 Output 53 54 ``` 55 2 56 He 57 llo 58 ``` 59 60 Input 61 62 ``` 63 10 9 5 64 Codeforces 65 ``` 66 67 Output 68 69 ``` 70 2 71 Codef 72 orces 73 ``` 74 75 Input 76 77 ``` 78 6 4 5 79 Privet 80 ``` 81 82 Output 83 84 ``` 85 -1 86 ``` 87 88 Input 89 90 ``` 91 8 1 1 92 abacabac 93 ``` 94 95 Output 96 97 ``` 98 8 99 a 100 b 101 a 102 c 103 a 104 b 105 a 106 c 107 ```