Educational Codeforces Round 4 A. The Text Splitting 水题
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 水题的更多相关文章
- Educational Codeforces Round 14 A. Fashion in Berland 水题
A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...
- 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 ...
- 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 ...
- Educational Codeforces Round 13 D. Iterated Linear Function 水题
D. Iterated Linear Function 题目连接: http://www.codeforces.com/contest/678/problem/D Description Consid ...
- Educational Codeforces Round 13 C. Joty and Chocolate 水题
C. Joty and Chocolate 题目连接: http://www.codeforces.com/contest/678/problem/C Description Little Joty ...
- Educational Codeforces Round 13 B. The Same Calendar 水题
B. The Same Calendar 题目连接: http://www.codeforces.com/contest/678/problem/B Description The girl Tayl ...
- Educational Codeforces Round 13 A. Johny Likes Numbers 水题
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes ...
- Educational Codeforces Round 12 A. Buses Between Cities 水题
A. Buses Between Cities 题目连接: http://www.codeforces.com/contest/665/problem/A Description Buses run ...
- Educational Codeforces Round 11 B. Seating On Bus 水题
B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...
随机推荐
- CMDB反思4
CMDB模型设计2 http://blog.vsharing.com/xqscool/A1275233.html 估计大家看到破子的这两篇都有点晕哈,我也有点晕. 两篇对比来看. 第1处,属性部分 ...
- coroutine in c 备忘
coroutine: stackless和stackful jmp 基于switch的trick: http://www.chiark.greenend.org.uk/~sgtatham/corout ...
- 黑马程序员——有关protocol的小结
在OC程序中经常会有这样的问题就是一个类想让其他类帮自己实现某些方法,然后再将结果返回给这个类:如何让一个类要找的代理去实现自己想要的方法呢? 这样就需要有一个协议,让能遵守协议的其他类都能实现协议中 ...
- Start SparkR in RStudio
Sys.setenv(SPARK_HOME="/usr/spark") .libPaths(c(file.path(Sys.getenv("SPARK_HOME" ...
- vs2013下自动注释的运用
1.首先是VAssistX,可以在VS的工具下,拓展和更新里面找到,然后下载安装即可: 以下为大家介绍一下怎么添加函数头注释:随便打开一个C++的工程,找到一个方法,右击函数名,然后依次点击“Refa ...
- C语言基础(不断更新)
1.memcpy. memmove.memccpy的区别 字符串函数功能查询 memcpy要求源串和目的串不能重叠 memccpy:copy直至遇到由参数指定的ch. memmove: 源串和目的串可 ...
- mongodb使用中遇到的问题汇总
1. 每次重新打开mongo,都会显示:forked process:xxxx ,然后用 find -name mongod.lock 进行搜索,发现在 ./var/lib/mongodb/ 目录下又 ...
- 【原创】开发Kafka通用数据平台中间件
开发Kafka通用数据平台中间件 (含本次项目全部代码及资源) 目录: 一. Kafka概述 二. Kafka启动命令 三.我们为什么使用Kafka 四. Kafka数据平台中间件设计及代码解析 五. ...
- Command Line Tools uninstall
sudo rm -rf /Library/Developer/CommandLineTools
- Codeforces Educational Codeforces Round 15 D. Road to Post Office
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...