九度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 ...
随机推荐
- shiro注解@RequiresPermissions多权限任选一参数用法
@RequiresPermissions(value={"xxx:xxx","xxx:xxx"},logical=Logical.OR)
- [LeetCode 题解]:Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...
- django 生命周期
客户端发送请求 客户端(浏览器) → 发送请求 → 服务器(wsgi) → 解析请求 → 服务器(Middleware) → process_request → 服务器(urls) → 通过路由寻vi ...
- leetcode 2 两数相加 JAVA
题目: 给出两个 非空 的链表用来表示两个非负的整数.其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字. 如果,我们将这两个数相加起来,则会返回一个新的链表来表示 ...
- 三、linux基础命令
1.已知/tmp 目录下已经存放了test.txt文件,如何执行命令才能把/mnt/test.txt拷贝到/tmp 下覆盖掉/tmp/test.txt,而让linux系统不提示是否覆盖 答:之所以会出 ...
- 2019 JUST Programming Contest J. Grid Beauty
J. Grid Beauty time limit per test 3.0 s memory limit per test 256 MB input standard input output st ...
- react学习之路-配制antd-mobile
经过将近三个月的使用,现在终于在我老大的带领下做完了一个react的项目,感觉还可以,最大的不足就是,对于react中的很多的东西都是掺杂着jq使用来做的,这是最不满意的一点吧,但是开发进度很近,只能 ...
- 【maven】---初识
前言 最近在研究自动化测试,其中的一个研究点儿就是maven,去download了一本书,看了看.下面是自己的从书中摘录的一些关于maven的概念性的东西. 内容 maven是什么? Maven是一个 ...
- ios 相机 自定义 相片的截取
前段时间公司需要做一个身份识别的功能,而系统相机无法满足要求,so自己自定义了. 上代码: .h文件 #import <UIKit/UIKit.h> #import <AVFound ...
- Badboy安装和介绍
Badboy安装和介绍 [前言] 欢迎来到我的博客 Badboy是用C++开发的动态应用测试工具,拥有强大的屏幕录制和回放功能,可提供图形结果分析功能,同时Badboy提供了将Web测试脚本直接导出生 ...