九度oj 1464 Hello World for U 2012年浙江大学计算机及软件工程研究生机试真题
题目1464:Hello World for U
时间限制:1 秒
内存限制:128 兆
特殊判题:否
提交:3872
解决:1082
- 题目描述:
-
Given any string of N (>=5) 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
lowoThat is, the characters must be printed in the original order, starting top-down from the left vertical line with n1 characters, then left to right along the bottom line with n2 characters, and finally bottom-up along the vertical line with n3 characters. And more, we would like U to be as squared as possible -- that is, it must be satisfied that n1 = n3 = max { k| k <= n2 for all 3 <= n2 <= N } with n1 + n2 + n3 - 2 = N.
- 输入:
-
There are multiple test cases.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.
- 输出:
-
For each test case, print the input string in the shape of U as specified in the description.
- 样例输入:
-
helloworld!
ac.jobdu.com
- 样例输出:
-
h !
e d
l l
lowor
a m
c o
. c
jobdu.
- 来源:
- 2012年浙江大学计算机及软件工程研究生机试真题
- 分析:
#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
string s;
int n1,n3;
while(cin>>s){
int len=s.length()-;
int n=len+;
int nn=n+;
while(nn%){
nn--;
}
n1=nn/;
//cout<<n1<<endl;
n3=n-n1*+;
int i=;
//cout<<n3<<endl;
for(;i<n1-;i++){
cout<<s[i];
int j=;
for(;j<n3-;j++){
cout<<" "; }
cout<<s[len-i]<<endl;
}
int k=i+n3;
for(;i<k;i++){
cout<<s[i];
}
cout<<endl;
}
return ;
}
九度oj 1464 Hello World for U 2012年浙江大学计算机及软件工程研究生机试真题的更多相关文章
- 九度oj 1001 A+B for Matrices 2011年浙江大学计算机及软件工程研究生机试真题
题目1001:A+B for Matrices 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:15235 解决:6172 题目描述: This time, you are supposed ...
- 九度oj 1437 To Fill or Not to Fill 2012年浙江大学计算机及软件工程研究生机试真题
题目1437:To Fill or Not to Fill 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:1488 解决:345 题目描述: With highways availabl ...
- 九度oj 1468 Sharing 2012年浙江大学计算机及软件工程研究生机试真题
题目1468:Sharing 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:2687 解决:550 题目描述: To store English words, one method is ...
- 九度OJ 1019 简单计算器 -- 2006年浙江大学计算机及软件工程研究生机试真题
题目地址:http://ac.jobdu.com/problem.php?pid=1019 题目描述: 读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值. 输入: ...
- 九度oj 1034 寻找大富翁 2009年浙江大学计算机及软件工程研究生机试真题
题目1034:寻找大富翁 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5323 解决:2123 题目描述: 浙江桐乡乌镇共有n个人,请找出该镇上的前m个大富翁. 输入: ...
- 九度oj 1031 xxx定律 2009年浙江大学计算机及软件工程研究生机试真题
题目1031:xxx定律 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:5153 解决:3298 题目描述: 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n ...
- 九度oj 1032 ZOJ 2009年浙江大学计算机及软件工程研究生机试真题
题目1032:ZOJ 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4102 解决:2277 题目描述: 读入一个字符串,字符串中包含ZOJ三个字符,个数不一定相等,按ZOJ的顺序输出,当 ...
- 九度oj 1006 ZOJ问题 2010年浙江大学计算机及软件工程研究生机试真题
题目1006:ZOJ问题 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:16244 解决:2742 题目描述: 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC.是 ...
- 九度oj 1004 Median 2011年浙江大学计算机及软件工程研究生机试真题
题目1004:Median 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:14162 解决:3887 题目描述: Given an increasing sequence S of N i ...
随机推荐
- .NET Core + gRPC 实现数据串流 (Streaming)
引入 gRPC 是谷歌推出的一个高性能优秀的 RPC 框架,基于 HTTP/2 实现.并且该框架对 .NET Core 有着优秀的支持.最近在做一个项目正好用到了 gRPC,遇到了需要串流传输的问题. ...
- 《Beginning Java 7》 - 7 - abstract class 抽象类 和 interface 接口
1. 抽象类: 为什么用抽象类: 一些 generic 的类本身并没有现实意义,所以不需要被实例化.比如动物,自然界没有动物这个物种,但却有无数的继承自动物的物种,那么动物本身可以是一个抽象类. 抽象 ...
- java 去最后一位字符 str.substring(0,str.length()-1)
String str = " 中国, 美国 , 意大利 ";String[] arr = str.split(",");for(int i1 =0;i1< ...
- TCP/IP学习笔记(2)-数据链路层
数据链路层有三个目的: 为IP模块发送和接收IP数据报. 为ARP模块发送ARP请求和接收ARP应答. 为RARP发送RARP请求和接收RARP应答 ip大家都听说过.至于ARP和RARP,ARP叫做 ...
- 数据库管理工具navicat基本使用方法——以MySql为例
mysq数据库管理工具navicat基本使用方法 https://www.cnblogs.com/neuedu/p/5876874.html
- PHP程序执行流程
1, PHP文件一定放在服务器的,但是PHP中不同的内容会在不同的地方执行.下图演示了浏览器请求一个php页面的流程. 2,时序图如下所示,在浏览器中输入url后,首先去本机hosts文件中解析ip地 ...
- 打造一款1kb大马并且处理D盾以及安全狗拦截与查杀
在之前sky666提到了关于大马被waf拦的问题,我决定手动去过一下bypass.可是发现怎么也过不去查杀,更别说拦截了.对此无奈,只好花了个通宵去处理一下.顺便一提,理论过所有Waf,并且被杀只需要 ...
- Java实现文件重命名
最近在做一个Android上面的一个文件管理器的apk,有文件名重命名和剪切的功能. 一般的思路如下: 重命名:先新建一个文件,复制原先的文件,读写文件,最后删除原先文件 剪切:先复制原先的文件,删除 ...
- [转]IOS UIView 之属性篇
[转载自:IOS UIView 之属性篇 From CSDN] UIView 继承于UIResponder 所遵守的协议有 NSCoding .UIAppearance. UI ...
- 一个python 服务器程序性能分析
该服务器为bono,启动11个进程. 1.设置cprofile 在启动服务的总入口设置cprofile if __name__=="__main__": import cProfi ...