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. 多种css3时尚侧栏菜单展开显示效果Off-Canvas Menu Effects

    今天我们想分享多种css3时尚侧栏菜单展开显示效果.侧边栏应用广泛,我们之前已经产生了一些效果灵感.风格演变,今天我们要展示一套新的灵感的现代效果.不同的布局和菜单的同步转换和页面可以让一切看起来更有 ...

  2. 开发框架XUtils

    xUtils 包含了很多实用的android工具. xUtils 最初源于Afinal框架,进行了大量重构,使得xUtils支持大文件上传,更全面的http请求协议支持(10种谓词),拥有更加灵活的O ...

  3. 记录一次cefsharp1输入法在win7下异常解决定位

    最近几天都被基于cefSharp封装的浏览器控件搞疯了!对于cefSharp基本满足当前所做项目的需求,但是有一个问题一直困扰我,那就是系统中偶尔会出现输入法不能转换到中文.而且这个问题似乎没有什么规 ...

  4. VS 2013 EFSQLITE

    在 vs 2013 上用 1.NuGet程序包来获取,它也会自动下载EF6的包 :system.Data.sqlite 他会自动下载 其它几个需要的包. 2.在Sqlite官网上下载对应的版本:htt ...

  5. 提问:"~"运算符

    本人有一段代码关于"~"运算符 public class m{ public static void main(String[] args){ int x=~5; System.o ...

  6. Scrum之Sprint会议

    Scrum的项目过程有一系列的Sprint组成. Sprint的长度一般控制在2-4周. 通过固定的周期保持良好的节奏. 产品的设计.开发.测试都在Sprint期间完成. Sprint结束时交付可以工 ...

  7. Visual Studio Profiler 跟踪检查每个exe dll 性能 执行时间 CPU占用情况的方法

  8. U盘FAT32文件系统

    一.FAT文件系统分为四个部分 参考别人的博客 1.http://blog.163.com/ourhappines@126/blog/static/121363154201311811495492/ ...

  9. utf8 和 UTF-8 的区别

    只有在MySQL中可以使用“utf-8”的别名“utf8”,但是在其他地方一律使用大写“UTF-8”.

  10. FZU 8月有奖月赛A Daxia & Wzc's problem (Lucas)

    Problem A Daxia & Wzc's problem Accept: 42    Submit: 228Time Limit: 1000 mSec    Memory Limit : ...