一个多月前写的题,既然没人写题解,那蒟蒻就写一篇吧

基本思路

既然是输出任意一个解,那么号的位置在那里是没有关系的。我的思路是默认*号在最后面,然后对输入的字符串输出的行数进行分类。

代码

#include<bits/stdc++.h>
using namespace std;
int a,b;
string s;
void print(int a,int b,int p)//打印结果
{
for(int i=;i<=a;i++)
{
for(int j=;j<=b;j++) printf("%c",s[p++]);
printf("\n");
}
}
signed main()
{
cin>>s;//输入字符串
//判断
if(s.size()%==)
{
a=s.size()/, b=;
printf("%d %d\n",a,b);
print(a,b,);
}
else
{
a=s.size()/+;
if(s.size()%a==)
{
b=s.size()/a;
printf("%d %d\n",a,b);
print(a,b,);
}
else
{
b=s.size()/a+;
printf("%d %d\n",a,b);
int cnt=, flag=;
for(int i=;i<=a;i++)
{
if(flag== && (s.size()-cnt)%(b-)==) b--, flag=;
for(int j=;j<=b;j++) printf("%c",s[cnt++]);
if(flag) printf("*");
printf("\n");
}
}
}
return ;
}

 

CF1032B Personalized Cup的更多相关文章

  1. Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3)B. Personalized Cup

    题意:把一长串字符串 排成矩形形式  使得行最小  同时每行不能相差大于等于两个字符 每行也不能大于20个字符 思路: 因为使得行最小 直接行从小到大枚举即可   每行不能相差大于等于两个字符相当于  ...

  2. Codeforces 1032 - A/B/C/D/E - (Undone)

    链接:http://codeforces.com/contest/1032/ 是真的真的真的忍不住想吐槽这题意是真的真的真的读不懂…… A - Kitchen Utensils - [简单数学题] 题 ...

  3. Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3) Solution

    A. Kitchen Utensils Water. #include <bits/stdc++.h> using namespace std; #define N 110 int n, ...

  4. java高cup占用解决方案

    项目中发现java cpu占用高达百分之四百,查看代码发现有一个线程在空转,拉高了cup while(true){ } 解决方案,循环中加入延迟:Thread.sleep(Time): 总结下排查CP ...

  5. UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  6. uva 6757 Cup of Cowards(中途相遇法,貌似)

    uva 6757 Cup of CowardsCup of Cowards (CoC) is a role playing game that has 5 different characters (M ...

  7. 【转】关于KDD Cup '99 数据集的警告,希望从事相关工作的伙伴注意

    Features From: Terry Brugger Date: 15 Sep 2007 Subject: KDD Cup '99 dataset (Network Intrusion) cons ...

  8. Facebook Hacker Cup 2014 Qualification Round 竞赛试题 Square Detector 解题报告

    Facebook Hacker Cup 2014 Qualification Round比赛Square Detector题的解题报告.单击这里打开题目链接(国内访问需要那个,你懂的). 原题如下: ...

  9. DP VK Cup 2012 Qualification Round D. Palindrome pairs

    题目地址:http://blog.csdn.net/shiyuankongbu/article/details/10004443 /* 题意:在i前面找回文子串,在i后面找回文子串相互配对,问有几对 ...

随机推荐

  1. Java Collection Framework 备忘点

    最顶端是两个接口,集合和映射——  Collection<T>  /  Map<K, V> List 列表 保持插入顺序 ArrayList 擅长随机读 LinkedList ...

  2. python 将IP地址转换成打包后的32位格式

    python 2.7 #!/usr/bin/env python # Python Network Programming Cookbook -- Chapter - # This program r ...

  3. c++示例 计算器

    #include <iostream> using namespace std; int main() { char op; float num1, num2; cout << ...

  4. Ubuntu 14.04 下安装redis后运行redis-cli 报出redis Connection refused错误【已解决】

    在运行redis-cli运行后爆出错误,看了网上的都没有用例如:改ip,注释bind 127.0.0.1,或者是先运行./redis-server redis.conf,都没有用 只需要: 找到red ...

  5. django报错TypeRError:__init__() missing 1 required positional argument: 'on_delete'

    在添加外键的时候,在括号里添加on_delete=models.CASCADE即可 on_delete=models.CASCADE是级联删除的意思,意思就是说当你更新或删除主键表,那外键表也会跟随一 ...

  6. 入门display:inline-block运用

    这是我第一篇博客,是我新的开始,我要用博客记录我的学习之旅,在这里我要感谢我的哥哥,他带我开阔了眼界,纠正了我的格局,给我带来了正能量.我是一个小白,学习的路还很长很长,学习了10天HTML与css, ...

  7. geth run

    geth --networkid 1201 --rpc --rpcapi eth,net,web3,personal,admin,miner --rpccorsdomain "*" ...

  8. QThreadPool类和QtConcurrent命名空间

    一.QThreadPool类  QThreadPool管理一组线程.它负责管理和回收单个QThread对象以减少程序中线程创建的开销.每个Qt应用程序都有一个全局的QThreadPool对象,可通过方 ...

  9. CDH构建大数据平台-Kerberos高可用部署【完结篇】

    CDH构建大数据平台-Kerberos高可用部署[完结篇] 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.安装Kerberos相关的软件包并同步配置文件 1>.实验环境 ...

  10. Zynq_soc学习

    Zynq_soc学习 SFP高速串行通信得搞来看看 最小系统 PL端时钟配置: 配置DDR控制器,主要是添加DDR正确的型号 外设电平接口配置: BANK0:LVCMOS3.3 BANK1:LVCMO ...