Description

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.

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".

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).

Input

The first line contains three positive integers n, p, q (1 ≤ p, q ≤ n ≤ 100).

The second line contains the string s consists of lowercase and uppercase latin letters and digits.

Output

If it's impossible to split the string s to the strings of length p and q print the only number "-1".

Otherwise in the first line print integer k — the number of strings in partition of s.

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.

If there are several solutions print any of them.

Sample Input

Input

5 2 3
Hello

Output

2
He
llo

Input

10 9 5
Codeforces

Output

2
Codef
orces

Input

6 4 5
Privet

Output

-1

Input

8 1 1
abacabac

Output

8
a
b
a
c
a
b
a
c
 #include<cstdio>
char s[];
int main()
{
int n,p,q,k,l1,l2,l,g;
while(scanf("%d %d %d",&n,&p,&q)!=EOF)
{
scanf("%s",&s);
g=;
for(int i = ; i <= n ; i++)
{
for( int j = ; j <= n ; j++)
{
if(i*p+j*q == n)
{
printf("%d\n",i+j);
k=-;
while(i--)
{
l=p;
while(l--)
{
printf("%c",s[++k]);
}
printf("\n");
}
while(j--)
{
l=q;
while(l--)
{
printf("%c",s[++k]);
}
printf("\n");
}
g=;
break;
}
}
if(g == ) break;
}
if(g != ) printf("-1\n"); } }

The Text Splitting (将字符串分成若干份,每份长度为p或q)的更多相关文章

  1. Educational Codeforces Round 4 A. The Text Splitting 水题

    A. The Text Splitting 题目连接: http://www.codeforces.com/contest/612/problem/A Description You are give ...

  2. Linux下的split 命令(将一个大文件根据行数平均分成若干个小文件)

    将一个大文件分成若干个小文件方法 例如将一个BLM.txt文件分成前缀为 BLM_ 的1000个小文件,后缀为系数形式,且后缀为4位数字形式 先利用 wc -l BLM.txt       读出 BL ...

  3. ACM2 递归 n分成k份

    //将n 分成k份的 分法总数 #include "stdafx.h" #include"stdio.h" #include<iostream> u ...

  4. java.text.MessageFormat格式化字符串时的小技巧

    java.text.MessageFormat格式化字符串时的小技巧 public static void main(String[] args) throws InterruptedExceptio ...

  5. 假设一个大小为100亿个数据的数组,该数组是从小到大排好序的,现在该数组分成若干段,每个段的数据长度小于20「也就是说:题目并没有说每段数据的size 相同,只是说每个段的 size < 20 而已」

    假设一个大小为100亿个数据的数组,该数组是从小到大排好序的,现在该数组分成若干段,每个段的数据长度小于20「也就是说:题目并没有说每段数据的size 相同,只是说每个段的 size < 20 ...

  6. HW—字符串最后一个单词的长度,单词以空格隔开。

    描述 计算字符串最后一个单词的长度,单词以空格隔开. 知识点 字符串,循环 运行时间限制 0M 内存限制 0 输入 一行字符串,长度小于128. 输出 整数N,最后一个单词的长度. 样例输入 hell ...

  7. OJ题:字符串最后一个单词的长度

    题目描述 计算字符串最后一个单词的长度,单词以空格隔开. 输入描述: 一行字符串,非空,长度小于5000. 输出描述: 整数N,最后一个单词的长度. 输入例子: hello world 输出例子: 5 ...

  8. 华为oj之字符串最后一个单词的长度

    题目: 字符串最后一个单词的长度 热度指数:9697 时间限制:1秒 空间限制:32768K 本题知识点: 字符串 题目描述 计算字符串最后一个单词的长度,单词以空格隔开. 输入描述: 一行字符串,非 ...

  9. 华为机试001:字符串最后一个单词的长度(华为OJ001)

    华为机试 字符串最后一个单词的长度 计算字符串最后一个单词的长度,单词以空格隔开. 提交网址: http://www.nowcoder.com/practice/8c949ea5f36f422594b ...

随机推荐

  1. Java标识符的习惯命名规范

    1 常量标识符:全部用大写字母和下划线表示.如SALES_MAX 2 类名或接口名:标识符用大写字母开头.如CreditCard 3 变量名和方法名:以小写字母开头,单词之间不要有分隔符,第二 及后面 ...

  2. HDFS执行getDatanodeReport时权限不足的解决办法

    通过JAVA获取HDFS的getDatanodeReport方法时,报权限不足的错误信息. org.apache.hadoop.ipc.RemoteException(org.apache.hadoo ...

  3. jmeter(七)函数

    JMeter函数是一些能够转化在测试树中取样器或者其他配置元件的域的特殊值.一个函数的调用就像这样:${_functionName(var1,var2,var3)},-functionName匹配函数 ...

  4. DEV—【GridControl添加按钮列】

    效果图 打开GridControl的Run Designer在左侧栏中找到: 添加一个ButtonEdit: 更改属性中的值:Caption为按钮上显示的Text:Kind为按钮的类型: 然后拖到最后 ...

  5. WCF入门大致思路

    WCF服务: 1.IServer.cs(类似接口,WCF接口) 2.Server.svc(实现了WCF接口)右键浏览器运行可以看到WCF服务链接,类似(http://localhost:4609/Us ...

  6. [转]C#Linq中的Union All/Union/Intersect和Top/Bottom和Paging和SqlMethods,skip,take,takewhile,skipwhile,编译查询等

    本文转自:http://www.cnblogs.com/suizhikuo/p/3791799.html 我们继续讲解LINQ to SQL语句,这篇我们来讨论Union All/Union/Inte ...

  7. AJPFX关于数组获取最值的思路和方法

    思路分析:1.定义一个变量(max,初始值一般为数组中的第一个元素值),用来记录最大值.2.遍历数组,获取数组中的每一个元素,然后依次和max进行比较.如果当前遍历到的元素比max大,就把当前元素值给 ...

  8. 从java toBinaryString() 看计算机数值存储方式(原码、反码、补码)

    一.toBinaryString 方法及其含义 1.1 方法说明 该方法位于java.lang.Integer类中 方法签名:public static String toBinaryString(i ...

  9. 正则表达式 - IP地址、Mac地址、端口、经纬度、车牌号码校验

    IP地址验证:   /^(\d|[1-9]\d|1\d{2}|2[0-5][0-5])\.(\d|[1-9]\d|1\d{2}|2[0-5][0-5])\.(\d|[1-9]\d|1\d{2}|2[0 ...

  10. oracle 创建表

    --创建表 create table browser_track( btId number not null , opend_id ) not null, url_address ) not null ...