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. 水题不AC,自挂二叉树——Chemist

    学长让我们刷USACO的水题果然是有道理的,做了四道挂了两道...细节处理一定要小心!大概都是NOIP Day1 T1的难度,但是一定要考虑全面否则还是凉凉啊. 一.USACO1.1贪婪的送礼者 题目 ...

  2. pip 的具体含义

    Python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip (pip3 for Pytho ...

  3. ssh 公钥登录远程主机

    ssh-keygen 然后一路回车就可以了 ssh-copy-id user@host user代表用户名,host代表主机地址 然后根据提示输入远程主机的密码,成功,再登录就不用输入密码了

  4. [Usaco2013 Jan]Island Travels

    Description Farmer John has taken the cows to a vacation out on the ocean! The cows are living on N ...

  5. AJPFX关于File类复习

    file是一个路径,分为相对路径(eclipse)和绝对路径:1.构造方法有:File(String pathname ),File(String parent ,String child),File ...

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

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

  7. phpmyadmin在linux下通过sock安装教程

    当初是按照 http://www.cnblogs.com/freeweb/p/5262852.html 地址参考安装,因为疏忽,未考虑到版本差异带来的影响(自身安装的是最新版 phpMyAdmin-4 ...

  8. SCHTASKS /CREATE

    SCHTASKS   "/" 这个符号前要加个空格才能运行成功  ,搞半天!

  9. 类的封装,property特性,类与对象的绑定方法和非绑定方法,

    类的封装 就是把数据或者方法封装起来 为什么要封装 封装数据的主要原因是:保护隐私 封装方法的主要原因是:隔离复杂度(快门就是傻瓜相机为傻瓜们提供的方法,该方法将内部复杂的照相功能都隐藏起来了,比如你 ...

  10. vsphere中的vcenter创建esxi模板虚拟机新建无法连接网络

    1.删除网卡配置文件下的uuid和hwaddr  这是因为虚拟机模板创建网卡mac没改变 2.删除规则文件 rm -f /etc/udev/rules.d/-prtsistent-net.rules ...