A. The Text Splitting

题目连接:

http://www.codeforces.com/contest/612/problem/A

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

5 2 3

Hello

Sample Output

2

He

llo

Hint

题意

给你一个字符串,让你分割成长度为p,或者长度为q的串

问你如何分割

题解:

数据范围很小,所以直接暴力枚举就好了

代码

#include<bits/stdc++.h>
using namespace std; string s;
int main()
{
int n,p,q;
cin>>n>>p>>q;
cin>>s;
for(int i=0;i<150;i++)
{
for(int j=0;j<150;j++)
{
if(i*p+j*q==s.size())
{
cout<<i+j<<endl;
for(int k=0;k<i;k++)
{
for(int t=0;t<p;t++)
cout<<s[k*p+t];
cout<<endl;
}
for(int k=0;k<j;k++)
{
for(int t=0;t<q;t++)
cout<<s[i*p+k*q+t];
cout<<endl;
}
return 0;
}
}
}
return puts("-1");
}

Educational Codeforces Round 4 A. The Text Splitting 水题的更多相关文章

  1. Educational Codeforces Round 14 A. Fashion in Berland 水题

    A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...

  2. Codeforces Educational Codeforces Round 3 B. The Best Gift 水题

    B. The Best Gift 题目连接: http://www.codeforces.com/contest/609/problem/B Description Emily's birthday ...

  3. Codeforces Educational Codeforces Round 3 A. USB Flash Drives 水题

    A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying ...

  4. Educational Codeforces Round 13 D. Iterated Linear Function 水题

    D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consid ...

  5. Educational Codeforces Round 13 C. Joty and Chocolate 水题

    C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...

  6. Educational Codeforces Round 13 B. The Same Calendar 水题

    B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Tayl ...

  7. Educational Codeforces Round 13 A. Johny Likes Numbers 水题

    A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...

  8. Educational Codeforces Round 12 A. Buses Between Cities 水题

    A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...

  9. Educational Codeforces Round 11 B. Seating On Bus 水题

    B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...

随机推荐

  1. hdu 4508 湫湫系列故事——减肥记I(完全背包)

    题意:完全背包 思路:完全背包 可以直接转化为 多重背包,num[i]=_v/c[i];//转为多重背包然后运用 多重背包 3种解法如下码1: #include<iostream> #in ...

  2. 庞锋 OpenCV 视频 学习进度备忘

    书签:另外跳过的内容有待跟进 学习资源: opencv视频教程目录(初级)   主讲:庞锋,毕业于电子科技大学 知识基础支持: 线性代数 应用数学 跳过的内容: 1.第1~6集跳过,简单.(2014- ...

  3. 字节顺序重置及“#include <algorith.h>”相关的STL最重要的头文件提醒

    这两天在写一个程序,需要将二进制文件中的数据以指定结构读入内存,说明文档中有提到大端序和小端序(Big Endian or Little Endian) 的概念,就找了一下字节顺序重置的算法,在一篇名 ...

  4. SQL和NOSQL有区别吗?

    在大数据高速发展的今天,数据量在不断的增加,传统的数据库可能不能满足人们的需求了,这个时候新霸哥注意到了NOSQL出现了可以解决这个问题.我们知道sql数据库可以存储数据和处理数据,但是NOSQL最大 ...

  5. 凸包稳定性判断:每条边上是否至少有三点 POJ 1228

    //凸包稳定性判断:每条边上是否至少有三点 // POJ 1228 #include <iostream> #include <cstdio> #include <cst ...

  6. IOS平台设计规范

    一.UI的控件概述: 1.框架UI的元素分为4类: A:栏:状态栏目和导航栏的结合体; B:内容视图:应用显示的内容信息,包括相关的交互行为,例如滚屏.插入.删除等操作进行排序; C:控制元素:产品行 ...

  7. 【转】SQL Server 数据库内部版本号

    -----------数据库还原或版本升级出现版本错误时可参考. Internal SQL Server Database Version Numbers A database created by ...

  8. C++学习之路--类的构建以及数据转换存储

    注意理解下面的代码,数据的处理与转换. 头文件: #ifndef STACK_H #define STACK_H class Stack { struct Link { void* data; Lin ...

  9. 关于WordPress建站的原理二三事

    在写关于仿站文章详情页如何制作之前,我觉得有必要就一些原理性的问题,做一些说明.文章详情页的核心模块和首页有很多相似的地方,比如调用文章的标题.文章的内容.文章分类.作者等,实现起来都差不多,因此,了 ...

  10. JQuery发送Put、Delete请求 - 摘自网络

    DELETE: $.ajax({ url: '/script.cgi', type: 'DELETE', success: function(result) { // Do something wit ...