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代码如下:
<pre name="code" class="cpp">#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char a[1100];
int main()
{int n,p,q,t;while(~scanf("%d%d%d",&n,&p,&q)){scanf("%s",a);int i,j,k,t,s=0;for(i=0;i<=n;i++){if(s!=0)break;for(j=0;j<=n;j++){if(i*p+j*q>n)break;if(i*p+j*q==n){printf("%d\n",i+j);s=1;int l=0;for(k=0;k<i*p;k++){printf("%c",a[l++]);if((k+1)%p==0)printf("\n");}for(t=0;t<j*q;t++){printf("%c",a[l++]);if((t+1)%q==0)printf("\n");}break;}}}if(!s)printf("-1\n");}}

CodeForces612AThe Text Splitting(枚举)相关推荐

  1. CodeForces612AThe Text Splitting(模拟,暴力枚举)

    Description You are given the string s of length n and the numbers p, q. Split the string s to piece ...

  2. The Text Splitting (将字符串分成若干份,每份长度为p或q)

    Description You are given the string s of length n and the numbers p, q. Split the string s to piece ...

  3. 一道暴力枚举题Win32版本示例

    来看一个问题:该问题的解法是 暴力枚举:这大概是ACM方面的:名称叫火柴棒等式: 给你n根火柴棍,你可以拼出多少个形如"A+B=C"的等式?等式中的A.B.C是用火柴棍拼出的整数( ...

  4. 《Deep Learning With Python second edition》英文版读书笔记:第十一章DL for text: NLP、Transformer、Seq2Seq

    文章目录 第十一章:Deep learning for text 11.1 Natural language processing: The bird's eye view 11.2 Preparin ...

  5. 《译 SFML Essentials 英文版》—— 《第五章》 “ Exploring a World of Sound and Text ”

    目录 Preface Audio module – overview Sound versus music Audio in action The sf::Sound class Introducin ...

  6. 根据枚举code获取枚举值

    枚举接口类BaseIntEnum package com.bt.common.core.enums;import java.util.*;/*** Enum implement this interf ...

  7. 爱上MVC~为Html.EditorForModel自定义模版

    回到目录 挺有意思的一件事 对于MVC视图渲染来说,大家应该不会陌生,但对于模型的渲染,不知道是否听说过,主要是说Model通过它属性的相关特性(DataType,UIHint)来将它们自动渲染到Vi ...

  8. mysql yintint类型_MySQL服务器2 被嫌弃的胖子

    1.sql的基本语法 对数据库 create database db1; 创建数据库 对表: create database t1(id int,name char(10)); 创建表 show cr ...

  9. MapReduce计数器

    原文链接:http://itfish.net/article/61067.html 1.MapReduce计数器是什么? 计数器是用来记录job的执行进度和状态的.它的作用可以理解为日志.我们可以在程 ...

最新文章

  1. 备忘录吕吕没有备忘录十新建_一份备忘单,可帮助您记住CSS自定义属性
  2. 第一家公立大学支持比特币支付学费
  3. 一万字,关于产品「需求」阶段的思维公式,都在这儿了
  4. 代码雨代码源复制_小程序基于Parser添加长按复制、代码高亮等功能
  5. 如何在.NET Core控制台程序中使用依赖注入
  6. Python Pandas读取修改excel操作攻略
  7. https的博客作业
  8. 安装nokogiri前提
  9. 如何发送Excel中图表到邮件
  10. Asp.Net实例:C# 绘制统计图(二) ——折线统计图的绘制
  11. ubuntu服务器长时间不连接显示器后,连上显示器没反应
  12. 安卓盒子root--包好
  13. 直角三角形的两个夹角度数计算(java)
  14. python计算纪念日相关
  15. Kubernetes知识整理
  16. 《Python程序设计(第3版)》[美] 约翰·策勒(John Zelle) 第 9 章 答案
  17. c语言中如何将字体弄大,CFree怎样调大字体
  18. Windows 8.1 更新错误 0x80073712 解决办法
  19. 语音信号处理第三章:
  20. Python 数据获取(五)—— 获取客户端渲染方式数据

热门文章

  1. JAVA JDK 1.6 API中文版.CHM打开chm提示,“ 已取消到该网页的导航”
  2. 关于AIR724模组HTTP POST一些记录
  3. MATLAB台大郭彦甫老师课程笔记:第十一课:线性回归方程式与线性系统
  4. MySql函数DATE_FORMAT( )基本用法
  5. 用友u8修改服务器id,用友u8服务器地址修改
  6. 黑客爱用的 HOOK 技术大揭秘!
  7. 我在互联网大厂当鉴黄师:不看黄图敲代码,同事全都是博士
  8. WP 平衡球游戏开发教程(二) -在XNA 渲染Farseer物理对象
  9. 【NLP】第7章 使用 GPT-3 引擎的Suprahuman Transformers的崛起
  10. 尚硅谷VUE课程的页签图标问题