HDU 多校对抗第三场 L Visual Cube
Problem L. Visual Cube
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 2127 Accepted Submission(s): 984
Problem Description
Little Q likes solving math problems very much. Unluckily, however, he does not have good spatial ability. Everytime he meets a 3D geometry problem, he will struggle to draw a picture.
Now he meets a 3D geometry problem again. This time, he doesn't want to struggle any more. As a result, he turns to you for help.
Given a cube with length a, width b and height c, please write a program to display the cube.
Now he meets a 3D geometry problem again. This time, he doesn't want to struggle any more. As a result, he turns to you for help.
Given a cube with length a, width b and height c, please write a program to display the cube.
Input
The first line of the input contains an integer T(1≤T≤50), denoting the number of test cases.
In each test case, there are 3 integers a,b,c(1≤a,b,c≤20), denoting the size of the cube.
In each test case, there are 3 integers a,b,c(1≤a,b,c≤20), denoting the size of the cube.
Output
For each test case, print several lines to display the cube. See the sample output for details.
Sample Input
2
1 1 1
6 2 4
Sample Output
题意:给你长方体的长宽高,要你构造出(画出,一个按照题目要求给的长方体
题解:真tm变态呜呜呜,这个题,考你码力和找规律的能力,代码看了就懂了
一个面一个面的画,因为长方体在平面上只能展现三个面,所以循环六次就可以画出来了
代码如下:
#include <map> #include <set> #include <cmath> #include <ctime> #include <stack> #include <queue> #include <cstdio> #include <cctype> #include <bitset> #include <string> #include <vector> #include <cstring> #include <iostream> #include <algorithm> #include <functional> #define fuck(x) cout<<"["<<x<<"]"; #define FIN freopen("input.txt","r",stdin); #define FOUT freopen("output.txt","w+",stdout); #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; typedef long long LL; typedef pair<int, int> PII; const int maxn = 1e5+5; char mp[400][400]; int main(){ #ifndef ONLINE_JUDGE FIN #endif int T; int a,b,c; scanf("%d",&T); while(T--){ memset(mp,0,sizeof(mp)); scanf("%d%d%d",&a,&b,&c); for(int i=a*2+3;i<=a*2+b*2+1;i+=2){ for(int j=1;j<=b*2+c*2+1;j++){ mp[j][i]=(j&1)?'+':'|'; } } for(int i=a*2+2;i<=a*2+b*2+1;i+=2){ for(int j=1;j<=b*2+c*2+1;j++){ mp[j][i]=(j&1)?'.':'/'; } } for(int i=1;i<=b*2;i+=2){ for(int j=b*2+2-i;j<=a*2+b*2+2-i;j++){ mp[i][j]=(j&1)?'+':'-'; } } for(int i=2;i<=b*2;i+=2){ for(int j=b*2+2-i;j<=a*2+b*2+2-i;j++){ mp[i][j]=(j&1)?'.':'/'; } } for(int i=2*b+1;i<=2*b+2*c+1;i+=2){ for(int j=1;j<=2*a+1;j++){ mp[i][j]=(j&1)?'+':'-'; } } for(int i=2*b+2;i<=2*b+2*c;i+=2){ for(int j=1;j<=2*a+1;j++){ mp[i][j]=(j&1)?'|':'.'; } } int x=c*2+b*2+1; int y=b*2+a*2+1; for(int i=1;i<=b*2;i++){ for(int j=1;j<=2*b-i+1;j++){ mp[x-i+1][y-j+1]='.'; } } for(int i=1;i<=b*2;i++){ for(int j=1;j<=2*b-i+1;j++){ mp[i][j]='.'; } } for(int i=1;i<=x;i++){ for(int j=1;j<=y;j++){ printf("%c",mp[i][j]); } printf("\n"); } } }
每一个不曾刷题的日子
都是对生命的辜负
从弱小到强大,需要一段时间的沉淀,就是现在了
~buerdepepeqi