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. [USACO 2012 Jan Silver] Delivery Route【拆点】

    传送门:http://www.usaco.org/index.php?page=viewproblem2&cpid=106 这道题还真是完全没思路,真的不知道怎么做,但是看了题解后恍然大悟. ...

  2. [转]Monkey测试简介

    转自:http://www.cnblogs.com/manuosex/p/3215270.html 在android手机上做自动化测试,monkey比cts,Android UnitTest 好用多了 ...

  3. [BZOJ1008][HNOI2008]越狱 组合数学

    http://www.lydsy.com/JudgeOnline/problem.php?id=1008 正着直接算有点难,我们考虑反着来,用全集减补集. 总的方案数为$m^n$.第一个人有$m$种可 ...

  4. Eclipse打包多渠道包(库工程版)

    请先移步多渠道打包http://www.cnblogs.com/bhm666/p/6438776.html 自从上次使用了Gradle打渠道包后,遇到了各种各样的问题,不过也是小问题,仍然在几个项目上 ...

  5. ubunut在线音乐比方软件

    今天安装了一个音乐在线播放软件,忍不住要来赞一下, 之前一直都是用网页在线的qq音乐听的,这样就有点感觉不爽了, 今天突然想起来好像在网上看到的在ubuntu下有用网易云音乐的,就上网看了一下 还真的 ...

  6. table鼠标滑过变颜色

    table鼠标滑过变颜色 添加 table tr:hover{background-color: #eee;} 设置鼠标滑过行背景变色,重新刷新浏览器页面.  一般设置灰色,eee

  7. Android(java)学习笔记192:ContentProvider使用之虚拟短信

    1.虚拟短信应用场景:   急着脱身?应付老婆(老公.男女朋友查岗)?   使用虚拟通话短信吧.您只需通过简单设置,软件就会在指定时间会模拟一个“真实”来电或短信来迷惑对方,通过“真实”的证据让对方相 ...

  8. COMMENT - 定义或者改变一个对象的评注

    SYNOPSIS COMMENT ON { TABLE object_name | COLUMN table_name.column_name | AGGREGATE agg_name (agg_ty ...

  9. ztree 展开一级节点 | ztree只显示到二级目录

    // 默认展开一级节点var nodes = tree.getNodesByParam("level", 0);for (var i = 0; i < nodes.lengt ...

  10. 谈谈JVM内存区域的划分

    我们知道,计算机CPU和内存的交互是最频繁的,内存是我们的高速缓存区,用户磁盘和CPU的交互,而CPU运转速度越来越快,磁盘远远跟不上CPU的读写速度,才设计了内存,用户缓冲用户IO等待导致CPU的等 ...