HDU 6330--Visual Cube(构造,计算)
- 将这个立方体分块,分成上中下三个部分,利用长宽高计算行列,最后输出即可。
每个部分都分成奇偶行来输出,总共有\(2*(b+c)+1\)行,共\(2*(a+b)+1\)列。设当前行为\(i\),划分方式:当行数小于等于\(2*b\)时,在上部,当$i > (2 * b) $ && \(i<=2*c+1\)时,在中部,其余在下部。这样的划分可以应对绝大部分情况,但是对于上部有一中情况是不包括的,当$b>c $时,如果继续之前的划分,那么在头部判定之后,它依然符合下部的判定,所以这时也被当作下部输出,这不是预期的结果,所以在上部加上额外的判定。
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main(void) {
int t, a, b, c;
cin >> t;
while (t-- > 0) {
cin >> a >> b >> c;
for (int i = 1; i <= (2 * (b + c) + 1); i++) {
//if (i != 1)cout << endl;
//head
if (i % 2 == 1 && i <= (2 * b)) {
for (int j = 1; j <= 2*(b-i/2); j++) {
cout << ".";
}
for (int j = 2 * (b - i / 2) + 1; j <= 2 * (b - i / 2) + a * 2; j+=2) {
cout << "+-";
}
cout << "+";
if (b < c || i <= (2 * c + 1)) {
for (int j = 2 * (b - i / 2) + a * 2 + 2; j <= 2 * (a + b) + 1; j += 2) {
cout << ".+";
}
}
else
{
cout << ".";
for (int j = 1; j <= c; j++) {
cout << "+.";
}
for (int j = 2 * (b - i / 2) + a * 2 + 2*c+3; j <= 2 * (a + b) + 1; j++) {
cout << ".";
}
}
cout << endl;
continue;
}
if (i % 2 == 0 && i <= (2 * b)) {
for (int j = 1; j <= 2 * (b - i / 2)+1; j++) {
cout << ".";
}
for (int j = 2 * (b - i / 2) + 1; j <= 2 * (b - i / 2) + a * 2; j += 2) {
cout << "/.";
}
if (b < c ||i<=(2*c+1)) {
for (int j = 2 * (b - i / 2) + a * 2 + 2; j <= 2 * (a + b) + 1; j += 2) {
cout << "/|";
}
}
else
{
cout << "/";
for(int j=1;j<=c;j++){
cout << "|/";
}
for (int j = 2 * (b - i / 2) + a * 2+2*c+3; j <= 2 * (a + b) + 1; j++) {
cout << ".";
}
}
cout << endl;
continue;
}
//middle
if (i % 2 == 1 && i > (2 * b)&& i<=2*c+1) {
for (int j = 1; j <= 2 * a; j+=2) {
cout << "+-";
}
cout << "+";
for (int j = 2 * (a+1); j <= 2 * (a + b) + 1; j += 2) {
cout << ".+";
}
cout << endl;
continue;
}
if (i % 2 == 0 && i > (2 * b) && i <= 2 * c + 1) {
for (int j = 1; j <= 2 * a; j+=2) {
cout << "|.";
}
cout << "|";
for (int j = 2 * (a + 1); j <= 2 * (a + b) + 1; j += 2) {
cout << "/|";
}
cout << endl;
continue;
}
//bottom
if (i % 2 == 1 && i > (2 * c + 1)) {
for (int j = 1; j <= 2 * a; j+=2) {
cout << "+-";
}
cout << "+";
int k = (2 * (c + b) + 1 - i) / 2+1;
for (int j = 1; j <= k-1; j++) {
cout << ".+";
}
for (int j = 2 * a + 1 + 2 * k; j <= 2 * (a + b) + 2; j++) {
cout << ".";
}
cout << endl;
continue;
}
if (i % 2 == 0 && i > (2 * c + 1)) {
for (int j = 1; j <= 2 * a; j+=2) {
cout << "|.";
}
int k = (2 * (c + b) + 1 - i) / 2+1;
for (int j = 1; j <= k; j++) {
cout << "|/";
}
for (int j = 2 * a + 1 + 2 * k; j <= 2 * (a + b) + 1; j++) {
cout << ".";
}
cout << endl;
continue;
}
}
}
return 0;
}
HDU 6330--Visual Cube(构造,计算)的更多相关文章
- HDU 多校对抗第三场 L Visual Cube
Problem L. Visual Cube Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java ...
- HDU 6330.Problem L. Visual Cube-模拟到上天-输出立方体 (2018 Multi-University Training Contest 3 1012)
6330.Problem L. Visual Cube 这个题就是输出立方体.当时写完怎么都不过,后来输出b<c的情况,发现这里写挫了,判断失误.加了点东西就过了,mdzz... 代码: //1 ...
- (2018 Multi-University Training Contest 3)Problem L. Visual Cube
//题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6330//题目大意:按照一定格式画出一个 a×b×c 的长方体. #include <b ...
- Problem L. Visual Cube(杭电多校2018年第三场+模拟)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6330 题目: 题意:给你长宽高,让你画出一个正方体. 思路:模拟即可,湘潭邀请赛热身赛原题,不过比那个 ...
- HDU 5573 Binary Tree 构造
Binary Tree 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5573 Description The Old Frog King lives ...
- hdu 5015 233 Matrix(构造矩阵)
http://acm.hdu.edu.cn/showproblem.php?pid=5015 由于是个二维的递推式,当时没有想到能够这样构造矩阵.从列上看,当前这一列都是由前一列递推得到.依据这一点来 ...
- HDU 5813 Elegant Construction 构造
Elegant Construction 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer ...
- HDU 5292 Pocket Cube 结论题
Pocket Cube 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5292 Description Pocket Cube is the 2×2× ...
- codeforces 323A. Black-and-White Cube 构造
输入n 1 <= n <= 100 有一个n * n * n 的立方体,由n ^ 3 个1 * 1 * 1 的单位立方体构成 要用white 和 black 2种颜色来染这n ^ 3个立方 ...
随机推荐
- Hibernate=====HQL实用技术
Hibernate支持三种查询语言:HQL查询.Criteria查询和原生SQL查询 HQL(hibernate Query Language,hibernate查询语言)是一种面向对象查询语言,其中 ...
- Bash 脚本语法
每次学了忘,忘了学,怎么记不住,因为长时间不用了 Bash 流程控制 循环 for循环 for item in $list do echo $item done 另一种与C语言类似的写法 ; i< ...
- 详解nodejs中使用socket的私聊和公聊的办法
详解nodejs中使用socket的私聊和公聊的办法 nodejs的应用中,关于socket应该是比较出彩的了,socket.io在github上有几万人的star,它的成功应该是不输于express ...
- UITableViewCell 分割线如何满屏
在iOS7中,UITableViewCell左侧会有默认15像素的空白.设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉. 但是在iOS8中,设置setSepar ...
- Prime Numbers in a Grid素数网格
&/@ Shorthand notation for Map If[PrimeQ[#], Framed@Style[#, Orange, Bold, 15], #] & /@ Rang ...
- 【PIC单片机】MPLAB X IDE快速入门指南
引言:近期由于项目实践需要,开始动手学习相关硬件知识.从PIC单片机入手. 单片机学习核心要点:查数据手册 配置寄存器 一.基于MPLAB X IDE配置位设置 MPLAB X IDE和MPLAB I ...
- 三大集合框架之map
Map 是一种把键对象和值对象映射的集合,它的每一个元素都包含一对键对象和值对象. Map没有继承于Collection接口 从Map集合中检索元素时,只要给出键对象,就会返回对应的值对象. Map是 ...
- 【Mysql】—— 报错:Can't call commit when autocommit=true
java.sql.SQLException: Can't call commit when autocommit=true at com.mysql.jdbc.SQLError.createSQLEx ...
- numpy cheat sheet
numpy cheat sheet https://files.cnblogs.com/files/lion-zheng/Numpy_Python_Cheat_Sheet.pdf
- wireshark抓取本地回环数据包
linux环境下,用tcpdump,可以用-i lo参数抓取环回接口的包.如果服务端和客户端安装在同一台机器上,调试时是很方便的.linux版的wireshark,选取网卡的菜单里也有lo选项,也 ...