冰淇淋(图形递归
来源:互联网 发布:类似比邻的软件 编辑:程序博客网 时间:2024/04/28 01:01
传送门
垃圾佬的冰淇淋
TimeLimit:1000MS MemoryLimit:128MB
64-bit integer IO format:%lld
已解决 | 点击收藏
Problem Description
垃圾佬在草稿纸上画了一颗爱心,如下
/\/\\ / \/
垃圾佬发现,3颗爱心可以拼接成一个冰淇淋(吃货),如下
/\/\/\/\\ /\ / \/\/\/ \ / \/
现在呢,垃圾佬想画出第N个冰淇淋(上面的分别为第1个,第2个冰淇淋)。可是他还有别的事情要忙。
SO,剩下的冰淇淋就要你来画了。
当然,报酬是有的。。
每画一个,垃圾佬会给你1000000000000000000000000000 mod 10美元的报酬
Input
一个整数N表示第几个冰淇淋
1<=N<=10。
Output
输出是你画好的冰淇淋。每行末尾没有多余的空格
SampleInput
3
SampleOutput
/\/\/\/\/\/\/\/\\ /\ /\ /\ / \/\/\/ \/\/\/ \ / \ / \/\/\/\/\/ \ /\ / \/\/\/ \ / \/
若要绘制一个n阶的冰淇淋,则需要绘制3个n-1阶的冰淇淋,递归下去即可。注意行末没有空格
//china no.1#pragma comment(linker, "/STACK:1024000000,1024000000")#include <vector>#include <iostream>#include <string>#include <map>#include <stack>#include <cstring>#include <queue>#include <list>#include <stdio.h>#include <set>#include <algorithm>#include <cstdlib>#include <cmath>#include <iomanip>#include <cctype>#include <sstream>#include <functional>#include <stdlib.h>#include <time.h>#include <bitset>using namespace std;#define pi acos(-1)#define PI acos(-1)#define endl '\n'#define srand() srand(time(0));#define me(x,y) memset(x,y,sizeof(x));#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)#define close() ios::sync_with_stdio(0); cin.tie(0);#define FOR(x,n,i) for(int i=x;i<=n;i++)#define FOr(x,n,i) for(int i=x;i<n;i++)#define W while#define sgn(x) ((x) < 0 ? -1 : (x) > 0)#define bug printf("***********\n");#define db doubletypedef long long LL;const int INF=0x3f3f3f3f;const LL LINF=0x3f3f3f3f3f3f3f3fLL;const int dx[]={-1,0,1,0,1,-1,-1,1};const int dy[]={0,1,0,-1,-1,1,-1,1};const int maxn=1e5+10;const int maxx=1e6+100;const double EPS=1e-8;const double eps=1e-8;const int mod=1e9+7;template<class T>inline T min(T a,T b,T c) { return min(min(a,b),c);}template<class T>inline T max(T a,T b,T c) { return max(max(a,b),c);}template<class T>inline T min(T a,T b,T c,T d) { return min(min(a,b),min(c,d));}template<class T>inline T max(T a,T b,T c,T d) { return max(max(a,b),max(c,d));}template <class T>inline bool scan_d(T &ret){char c;int sgn;if (c = getchar(), c == EOF){return 0;}while (c != '-' && (c < '0' || c > '9')){c = getchar();}sgn = (c == '-') ? -1 : 1;ret = (c == '-') ? 0 : (c - '0');while (c = getchar(), c >= '0' && c <= '9'){ret = ret * 10 + (c - '0');}ret *= sgn;return 1;}inline bool scan_lf(double &num){char in;double Dec=0.1;bool IsN=false,IsD=false;in=getchar();if(in==EOF) return false;while(in!='-'&&in!='.'&&(in<'0'||in>'9'))in=getchar();if(in=='-'){IsN=true;num=0;}else if(in=='.'){IsD=true;num=0;}else num=in-'0';if(!IsD){while(in=getchar(),in>='0'&&in<='9'){num*=10;num+=in-'0';}}if(in!='.'){if(IsN) num=-num;return true;}else{while(in=getchar(),in>='0'&&in<='9'){num+=Dec*(in-'0');Dec*=0.1;}}if(IsN) num=-num;return true;}void Out(LL a){if(a < 0) { putchar('-'); a = -a; }if(a >= 10) Out(a / 10);putchar(a % 10 + '0');}void print(LL a){ Out(a),puts("");}//freopen( "in.txt" , "r" , stdin );//freopen( "data.txt" , "w" , stdout );//cerr << "run time is " << clock() << endl;char picture[1<<12][1<<12];int bin[13];void draw(int r,int c,int n){ if (n==1) { picture[r][c]='/';picture[r][c+1]='\\';picture[r][c+2]='/';picture[r][c+3]='\\'; picture[r+1][c]='\\';picture[r+1][c+3]='/'; picture[r+2][c+1]='\\'; picture[r+2][c+2]='/'; } else { draw(r,c,n-1); draw(r,c+bin[n],n-1); draw(r+bin[n-1],c+bin[n-1],n-1); }}void print(int n){ for (int i=1;i<bin[n+1];++i) { for (int j=bin[n+1];j>=1;--j) { if (picture[i][j]!=' ') { picture[i][j+1]=0; puts(picture[i]+1); break; } } }}int main(){ bin[0]=1; for (int i=1;i<=11;++i) bin[i]=bin[i-1]*2; int n; scanf("%d",&n); for (int i=0;i<=bin[n+1];++i) for (int j=0;j<=bin[n+1];++j) picture[i][j]=' '; draw(1,1,n); print(n); return 0;}
阅读全文
0 0
- 冰淇淋(图形递归
- 【递归输出图形】POJ_1941
- 雨中一盒冰淇淋
- 牛奶提子冰淇淋
- 骆驼奶的冰淇淋
- 汽车对冰淇淋过敏
- 芒果冰淇淋做法
- o.boj 1446 冰淇淋
- 香草冰淇淋的故事
- C-多线程,冰淇淋问题
- python数据结构与算法 22 递归图形
- poj 3768 递归(绘制图形)
- 用递归画的有意思的图形
- 递归使用案例:输出对称图形
- java基础代码-打印图形-递归
- 老船长冰淇淋新资助
- 脚踩冰淇淋的滋味
- 买香草冰淇淋汽车就会秀逗
- Android7.0解决 android.os.FileUriExposedException: file:///storage/emulated/0/
- SecureCRT连接虚拟机中的Linux系统(Ubuntu)
- java数据结构与算法-栈
- Django学习之路(六)Models和数据库
- 深入理解Objective-C: Autorelease Pool (自动释放池)
- 冰淇淋(图形递归
- java-抛出异常
- 进程通信—卖票系统的实现
- 清除canvas画布内容--点擦除+线擦除
- ADS1018编程步骤
- 动态时钟javascript
- redis--内部结构--quicklist
- 分布式系统架构fastDFS与RPC中间件的区别
- RMQ问题(未完待续)