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. 使用IDEA创建java项目(hello word)

    前提:已安装好jdk,配置好环境变量.我使用的是java 8. 首先在自己的D盘下建一个文件夹,用来存放我们待会新建的项目,我创建了IdeaProject: 1,第一步打开idea 第二步选择创建ja ...

  2. 重构指南 - 尽快返回(Return ASAP )

    尽快返回就是如果方法中的条件判断可以得到结果,则尽快返回该结果. 1. 检查条件,如果不满足就立即返回,不执行下面的逻辑. 2. 当包含大量的if else嵌套,代码可读性变差,也容易出现异常. 3. ...

  3. Csharp:asp.net CheckBoxList databind

    /// <summary> /// CheckBoxList數據源 /// 塗聚文 /// 20130705 /// /// </summary> private void s ...

  4. ubuntu GITLAB完全导入SVN(提交历史,用户)项目

    从SVN导入到GITLAB目前没有直接的方案,通常需要通过GIT转换:SVN –>GIT –>GITLAB.通过这种方式,将SVN的提交历史,用户信息一并导入到gitlab 注:本文只适用 ...

  5. Tesorflow源代码安装方式以及错误的解决方法

    作者 修雨轩陈@cnblog 目录 Configure the installation. (安装配置) Create the pip package and install (创建pip安装包并且安 ...

  6. 《ArcGIS Runtime SDK for Android开发笔记》——(15)、要素绘制Drawtools3.0工具DEMO

    1.前言 移动GIS项目开发中点线面的要素绘制及编辑是最常用的操作,在ArcGIS Runtime SDK for iOS 自带AGSSketchLayer类可以帮助用户快速实现要素的绘制,图形编辑. ...

  7. dl +rec

    AutoEncoder http://blog.csdn.net/studyless/article/details/70880829

  8. 保存及读取keras模型参数

    转自:http://blog.csdn.net/u010159842/article/details/54407745,感谢分享~ 你可以使用model.save(filepath)将Keras模型和 ...

  9. attention

    attention: 时序的刻画 attention 在recommendation 中的应用: 年龄的增长, 对于商品的喜好 Dynamic attention deeo model:

  10. Python tqdm show progress bar

    tqdm can help to show a smart progress bar, and it is very easy to use, just wrap any iterable with  ...