Given any string of N (≥) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as:

h  d
e l
l r
lowo

That is, the characters must be printed in the original order, starting top-down from the left vertical line with n​1​​ characters, then left to right along the bottom line with n​2​​ characters, and finally bottom-up along the vertical line with n​3​​ characters. And more, we would like U to be as squared as possible -- that is, it must be satisfied that n​1​​=n​3​​=max { k | k≤n​2​​ for all 3 } with n​1​​+n​2​​+n​3​​−2=N.

Input Specification:

Each input file contains one test case. Each case contains one string with no less than 5 and no more than 80 characters in a line. The string contains no white space.

Output Specification:

For each test case, print the input string in the shape of U as specified in the description.

Sample Input:

helloworld!

Sample Output:

h   !
e d
l l
lowor
测试点5没过
 #define _CRT_SECURE_NO_WARNINGS
#include <climits>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
void printBlock(int n)
{
while (n--)
cout << " ";
}
int main()
{
string s;
cin >> s;
int N = s.length() - ;
int n1=, n2=;
int flag = ;
for (n2 = ; n2 <= N; n2++)
{
for (n1=;n1 <= n2; n1++)
if ( * n1 + n2 == s.length())
{
flag = ;
break;
}
if (flag)
break;
}
for (int i = ; i < n1; i++)
{
cout << s[i];
printBlock(n2 - );
cout << s[s.length() - i - ] << endl;
}
cout << s.substr(n1, n2);
return ;
}

1031 Hello World for U (20分)的更多相关文章

  1. PAT 甲级 1031 Hello World for U (20 分)(一开始没看懂题意)

    1031 Hello World for U (20 分)   Given any string of N (≥) characters, you are asked to form the char ...

  2. PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642 题目描述: Given any string of N (≥5) ...

  3. PAT Advanced 1031 Hello World for U (20 分)

    Given any string of N (≥) characters, you are asked to form the characters into the shape of U. For ...

  4. 【PAT甲级】1031 Hello World for U (20 分)

    题意: 输入一个字符串长度为5~80,以'U'型输出,使得底端一行字符数量不小于侧面一列,左右两列长度相等. trick: 不把输出的数组全部赋值为空格为全部答案错误,可能不赋值数组里值为0,赋值后是 ...

  5. 1031 Hello World for U (20 分)

    1031 Hello World for U (20 分) Given any string of N (≥5) characters, you are asked to form the chara ...

  6. 抛弃EF,20分构建一个属于自己的ORM框架

    Poiuyt_cyc 博客园首页新随笔联系订阅管理随笔 - 11  文章 - 0  评论 - 111 抛弃EF,20分构建一个属于自己的ORM框架 相信EF大家都不陌生了,因为数据库表跟程序实体是一一 ...

  7. PTA 邻接表存储图的广度优先遍历(20 分)

    6-2 邻接表存储图的广度优先遍历(20 分) 试实现邻接表存储图的广度优先遍历. 函数接口定义: void BFS ( LGraph Graph, Vertex S, void (*Visit)(V ...

  8. #020PAT 没整明白的题L1-009 N个数求和 (20 分)

    后面的测试点过不去,两个错误一个超时. 目前未解决   L1-009 N个数求和 (20 分)   本题的要求很简单,就是求N个数字的和.麻烦的是,这些数字是以有理数分子/分母的形式给出的,你输出的和 ...

  9. L1-023 输出GPLT (20 分)

    L1-023 输出GPLT (20 分) 给定一个长度不超过10000的.仅由英文字母构成的字符串.请将字符重新调整顺序,按GPLTGPLT....这样的顺序输出,并忽略其它字符.当然,四种字符(不区 ...

随机推荐

  1. 【春招】 java static 执行顺序

    package static类型.执行顺序; public class Test { Person person = new Person("Test"); static{ Sys ...

  2. Spring Boot从入门到精通(九)整合Spring Data JPA应用框架

    JPA是什么? JPA全称Java Persistence API,是Sun官方提出的Java持久化规范.是JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中. ...

  3. Python——项目-小游戏

    开始我们的项目 飞机大战 1 项目的初体验 以及前期准备 游戏初体验画面 验证一下本地第三方包有没有导入 python3 -m pygame.examples.aliens 如果没有出现游戏画面请先安 ...

  4. html5 拖放购物车

    1.本例中模仿了购物车添加的功能 主要运用了ondragstart / ondragover/ ondrag 功能 功能比较简单 遗留问题:火狐下图片拖进会被打开 <!doctype html& ...

  5. node 微信支付

    基于node 实现微信支付功能 需要了解的网站:微信支付 流程图: 1. 1.我的路由: const Koa = require('koa') const app = new Koa() const ...

  6. NLP(二十七)开放领域的三元组抽取的一次尝试

      当我写下这篇文章的时候,我的内心是激动的,这是因为,自从去年6月份写了文章利用关系抽取构建知识图谱的一次尝试 后,我就一直在试图寻找一种在开放领域能够进行三元组抽取的办法,也有很多读者问过我这方面 ...

  7. Natas22 Writeup(header重定向、burp截取抓包)

    Natas22: 打开页面是一个空白页面,查看源码,看起来好像是需要我们在url中添加“revelio”参数即可,然而实验了之后发现浏览器跳转回了原来的页面. 再次仔细审计源码,会看到页面开头有一个重 ...

  8. 深夜,我用python爬取了整个斗图网站,不服来斗

    QQ.微信斗图总是斗不过,索性直接来爬斗图网,我有整个网站的图,不服来斗. 废话不多说,选取的网站为斗图啦,我们先简单来看一下网站的结构 网页信息 从上面这张图我们可以看出,一页有多套图,这个时候我们 ...

  9. hdu1015+hdu1016 都是十分钟以内的深搜题

    hdu1015:给定一串可用序列值,每个字符映射到一个1-26之间的整数,选择五个有序数使得满足 a-b2+c3-d4+e5=target. #include<iostream> #inc ...

  10. java实现SSO(SingleSignOn)单点登录服务

    单点登录SSO:是指用户通过一次登录,可以访问任意所有相互信任的应用系统.即一处登录,处处登录.比如阿里系下的淘宝.天猫等,虽然是不同的产品,但归于一个体系下,是可以相互信任的应用系统. 为了方便用户 ...