我一开始的想法是间断性的输出空格和solve(k-1)

但是发现问题很大。

雨菲:可以用一个数组保存啊

我:那不爆了?

雨菲:不会爆。

我一算:729 × 729,还真没爆。

然后就直接WA了......

仔细观察,发现要输出X,而我输出x

然后就A了。

大水题。

 #include <cstdio>
/**
made with Unity
poj 2083
*/
using namespace std;
const int N = ;
char G[N][N];
inline int pow(int a, int b) {
int ans = ;
for(int i = ; i <= b; i++) {
ans *= a;
}
return ans;
} void solve(int k, int x, int y) {
if(k == ) {
G[x][y] = 'X';
return;
}
int len = pow(, k - );
solve(k - , x, y);
solve(k - , x + * len, y);
solve(k - , x + * len, y + * len);
solve(k - , x, y + * len);
solve(k - , x + len, y + len);
return;
} int main() {
int n;
while(scanf("%d", &n)) {
if(n == -) {
break;
}
for(int i = ; i < N; i++) {
for(int j = ; j < N; j++) {
G[i][j] = ' ';
}
}
solve(n, , );
int len = pow(, n - );
for(int i = ; i < len; i++) {
for(int j = ; j < len; j++) {
putchar(G[i][j]);
}
printf("\n");
}
printf("-\n");
} return ;
}

AC代码

poj2083 Fractal的更多相关文章

  1. $Poj2083/AcWing118\ Fractal$ 模拟

    $AcWing$ $Sol$ 一年前做过差不多的南蛮图腾,当时做出来还是很有成就感的$OvO$ $N<=7$,就是模拟模拟,预处理一下,$over$ $Code$ #include<bit ...

  2. Mysql存储引擎之TokuDB以及它的数据结构Fractal tree(分形树)

    在目前的Mysql数据库中,使用最广泛的是innodb存储引擎.innodb确实是个很不错的存储引擎,就连高性能Mysql里都说了,如果不是有什么很特别的要求,innodb就是最好的选择.当然,这偏文 ...

  3. POJ 2083 Fractal

    Fractal Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6646   Accepted: 3297 Descripti ...

  4. POJ1941 The Sierpinski Fractal

    Description Consider a regular triangular area, divide it into four equal triangles of half height a ...

  5. 分形树Fractal tree介绍——具体如何结合TokuDB还没有太懂,先记住其和LSM都是一样的适合写密集

    在目前的Mysql数据库中,使用最广泛的是innodb存储引擎.innodb确实是个很不错的存储引擎,就连高性能Mysql里都说了,如果不是有什么很特别的要求,innodb就是最好的选择.当然,这偏文 ...

  6. C - Fractal(3.4.1)

    Description A fractal is an object or quantity that displays self-similarity, in a somewhat technica ...

  7. 2015北京网络赛 H题 Fractal 找规律

    Fractal Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc2015beijingo ...

  8. Fractal(递归,好题)

    Fractal Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8341   Accepted: 3965 Descripti ...

  9. - Fractal(3.4.1)

    C - Fractal(3.4.1) Time Limit:1000MS    Memory Limit:30000KB    64bit IO Format:%I64d & %I64u Su ...

随机推荐

  1. 极验3.0滑动拼图验证的使用--java

    [ 前言: 在登录其他网站的时候,看到有个滑动拼图的验证觉得挺好玩的,以前做一个图片验证的小demo,现在发现很多网站都开始流行滑动拼图的验证了,今天也想自己动手来弄一个. 废话不多说,开始撸起来! ...

  2. python语法糖/装饰器

    1.python高阶函数和嵌套函数 1.1高阶函数 def func1(x): return x**2 def func2(x): return x**3 def func(x,y): return ...

  3. python爬虫之正则表达式

    一.简介 正则表达式,又称正规表示式.正规表示法.正规表达式.规则表达式.常规表示法(英语:Regular Expression,在代码中常简写为regex.regexp或RE),计算机科学的一个概念 ...

  4. React Native & Android & iOS

    React Native & Android & iOS React Native & Android & iOS https://facebook.github.io ...

  5. BugFree 安装

    BugFree基于PHP和MySQL开发,是免费且开发源代码的缺陷管理系统.服务器端在Linux和Windows平台上都可以运行:客户端无需安装任何软件,通过IE,FireFox等浏览器就可以自由使用 ...

  6. Java使用RabbitMQ之整合Spring(消费者)

    依赖包: <!--RabbitMQ集成spring--> <!-- https://mvnrepository.com/artifact/org.springframework.am ...

  7. SpringMvc父子容器

      使用监听器listener来加载spring的配置文件:如下 <context-param> <param-name>contextConfigLocation</p ...

  8. Web API2 使用默认Identity

    当您选择个人账户在Web API项目模板,项目包含一个令牌授权服务器验证用户凭证和问题.下面的图显示了相同的凭证流的Web API组件. 发送一个未经授权的请求 首先,运行应用程序并单击按钮调用的AP ...

  9. Luogu1137 旅行计划(拓扑排序)

    题目传送门 拓扑排序板子题,模拟即可. 代码 #include<cstdio> #include<iostream> #include<cmath> #includ ...

  10. Qt 使用openGL 渲染NV12格式的视频

    直接上代码 Nv12Render.h #ifndef NV12RENDER_H #define NV12RENDER_H #include <QOpenGLFunctions> #incl ...