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(构造,计算)的更多相关文章

  1. HDU 多校对抗第三场 L Visual Cube

    Problem L. Visual Cube Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java ...

  2. HDU 6330.Problem L. Visual Cube-模拟到上天-输出立方体 (2018 Multi-University Training Contest 3 1012)

    6330.Problem L. Visual Cube 这个题就是输出立方体.当时写完怎么都不过,后来输出b<c的情况,发现这里写挫了,判断失误.加了点东西就过了,mdzz... 代码: //1 ...

  3. (2018 Multi-University Training Contest 3)Problem L. Visual Cube

      //题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6330//题目大意:按照一定格式画出一个 a×b×c 的长方体.  #include <b ...

  4. Problem L. Visual Cube(杭电多校2018年第三场+模拟)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6330 题目: 题意:给你长宽高,让你画出一个正方体. 思路:模拟即可,湘潭邀请赛热身赛原题,不过比那个 ...

  5. HDU 5573 Binary Tree 构造

    Binary Tree 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5573 Description The Old Frog King lives ...

  6. hdu 5015 233 Matrix(构造矩阵)

    http://acm.hdu.edu.cn/showproblem.php?pid=5015 由于是个二维的递推式,当时没有想到能够这样构造矩阵.从列上看,当前这一列都是由前一列递推得到.依据这一点来 ...

  7. HDU 5813 Elegant Construction 构造

    Elegant Construction 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5813 Description Being an ACMer ...

  8. HDU 5292 Pocket Cube 结论题

    Pocket Cube 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5292 Description Pocket Cube is the 2×2× ...

  9. codeforces 323A. Black-and-White Cube 构造

    输入n 1 <= n <= 100 有一个n * n * n 的立方体,由n ^ 3 个1 * 1 * 1 的单位立方体构成 要用white 和 black 2种颜色来染这n ^ 3个立方 ...

随机推荐

  1. 前端参数统一校验工具类ValidParamUtils

    1,前端参数不可信,对于后端开发人员来说应该是一条铁律,所以对于前端参数的校验,必不可少,而统一的前端参数校验工具,对我们进行参数校验起到事半功倍的效果 2,统一参数校验工具ValidParamUti ...

  2. 前端如何使用proxyTable和nginx解决跨域问题

    最近经常遇到跨域的问题,有时候问题虽然解决了,但是还是会有些模棱两可概念不清,于是在网上看了一些教程结合实际使用,做个笔记. 1.跨域原因 浏览器的限制 跨域(协议/域名/端口的不同) XMLHttp ...

  3. HTML表格相关元素

    <table> 标签定义 HTML 表格.简单的 HTML 表格由 table 元素以及一个或多个 tr.th 或 td 元素组成.tr 元素定义表格行,th 元素定义表头,td 元素定义 ...

  4. css3 转换 过渡 及动画

    转换transform: 通过 CSS3 转换,我们能够对元素进行移动.缩放.转动.拉长或拉伸.您可以使用 2D 或 3D 转换来转换您的元素 2D转换属性: transform 向元素应用 2D 或 ...

  5. show与ShowDialog substring

    substring public String substring(int beginIndex, int endIndex) 返回一个新字符串,它是此字符串的一个子字符串.该子字符串从指定的 beg ...

  6. String字符串操作

    char chars[] ={'a','b','c'}; String s = new String(chars); int len = s.length();//字符串长度 System.out.p ...

  7. 关于Android中的ViewTreeObserver

    ViewTreeObserver结构 extends Object java.lang.Object ↳ android.view.ViewTreeObserver ViewTreeObserver概 ...

  8. jdk时区相差8小时

    设置JVM的默认时区为东八区(北京时间)在下面四个目录(jre6\lib\zi\Etc.jre6\lib\zi.jdk1.6.0_18\jre\lib\zi\Etc.jdk1.6.0_18\jre\l ...

  9. JUnit_BeforeClass不报异常的 bug 处理

    1.try{} cathce(Exception e){}将觉得会出问题的地方括起来测试. 2.main方法调用出问题的方法.

  10. 【Python自然语言处理】第一章学习笔记——搜索文本、计数统计和字符串链表

    这本书主要是基于Python和一个自然语言工具包(Natural Language Toolkit, NLTK)的开源库进行讲解 NLTK 介绍:NLTK是一个构建Python程序以处理人类语言数据的 ...