Fractal---POJ2083(dfs)
http://poj.org/problem?id=2083
一道我认为有点恶心的dfs 刚开始没有初始化 用G++交 一直TLE 后来用了C++竟然是wa 那这肯定是我的问题了
最后发现没有初始化
dfs还是感觉不是太懂 什么时候才能真正学会
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
#include<iostream> using namespace std; #define N 1100
#define INF 0xffffffff
#define memset(a,b) memset(a,b,sizeof(a)) char str[N][N]; void DFS(int n,int x,int y)
{
if(n==)
{
str[x][y]='X';
return;
} int h=pow(3.0, n-); DFS(n-,x,y);///左上角
DFS(n-,x,y+*h);///右上角
DFS(n-,x+h,y+h);///中间
DFS(n-,x+*h,y);///左下角
DFS(n-,x+*h,y+*h);///右下角
} int main()
{
memset(str,' ');
DFS(,,); int m; while(scanf("%d",&m),m!=-)
{
int d=pow(3.0,m-);
for(int i=;i<=d;i++)
{
for(int j=;j<=d;j++)
{
printf("%c",str[i][j]);
}
printf("\n");
}
printf("-\n");
}
return ;
}
Fractal---POJ2083(dfs)的更多相关文章
- A过的题目
1.TreeMap和TreeSet类:A - Language of FatMouse ZOJ1109B - For Fans of Statistics URAL 1613 C - Hardwood ...
- poj2083 Fractal
我一开始的想法是间断性的输出空格和solve(k-1) 但是发现问题很大. 雨菲:可以用一个数组保存啊 我:那不爆了? 雨菲:不会爆. 我一算:729 × 729,还真没爆. 然后就直接WA了.... ...
- $Poj2083/AcWing118\ Fractal$ 模拟
$AcWing$ $Sol$ 一年前做过差不多的南蛮图腾,当时做出来还是很有成就感的$OvO$ $N<=7$,就是模拟模拟,预处理一下,$over$ $Code$ #include<bit ...
- POJ 2083 Fractal
Fractal Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6646 Accepted: 3297 Descripti ...
- Fractal(递归,好题)
Fractal Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8341 Accepted: 3965 Descripti ...
- ( 递归 )Fractal -- POJ -- 2083
http://poj.org/problem?id=2083 Fractal Time Limit: 1000MS Memory Limit: 30000K Total Submissions: ...
- POJ 2083 Fractal 分形题目
这两天自学了一线算法导论里分治策略的内容,秉着只有真正投入投入编程,才能更好的理解一种算法的思想的想法,兴致勃勃地找一些入门的题来学习. 搜了一下最后把目光锁定在了Poj fractal这一个题上.以 ...
- POJ 3845 Fractal(计算几何の旋转缩放)
Description Fractals are really cool mathematical objects. They have a lot of interesting properties ...
- poj2083 分形(图形的递归)
题目传送门 代码有注释. #include<iostream> #include<algorithm> #include<cstdlib> #include< ...
- poj--2083--Fractal(dfs)
Fractal Time Limit: 1000MS Memory Limit: 30000KB 64bit IO Format: %I64d & %I64u Submit Statu ...
随机推荐
- Quartz使用二 通过属性传递数据
上一篇介绍了通过context.getJobDetail().getJobDataMap()方式获取传递的数据,其实可以通过定义属性来传递参数 package org.tonny.quartz; im ...
- 洛谷 P1955 程序自动分析
题目描述 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3...代表程序中出现的变量,给定n个形如xi=xj或xi≠xj的变 ...
- 【C++】cerr,cout,clog
http://stackoverflow.com/questions/16772842/what-is-the-difference-between-cout-cerr-clog-of-iostrea ...
- android和IOS长连接区别
http://blog.csdn.net/zhangzeyuaaa/article/details/39028369 首先我们必须知道,所有的推送功能必须有一个客户端和服务器的长连接,因为推送是由服务 ...
- 一条update语句优化小记
遇到性能问题的sql如下: sql1: UPDATE amlclientlevel a SET a.client_value = (SELECT l.client_value ...
- C++友元函数和运算符重载
非成员友元函数.成员友元函数和友元类 1.友元的作用: (1)友元提供了不同类的成员函数之间.类的成员函数与一般函数之间进行了数据共享的机制: 2.友元的优点和缺点 优点:提高程序的运行效率: 缺点: ...
- 让idea调试不进入class文件中去
- kubeadm1.14.1 安装Metrics Server
Metrics API 介绍Metrics-Server之前,必须要提一下Metrics API的概念 Metrics API相比于之前的监控采集方式(hepaster)是一种新的思路,官方希望核心指 ...
- SpringCloud源码地址
SpringCloud实战源代码 https://github.com/springcloud/spring-cloud-code.git
- sql语句中嵌套2层循环
declare @year intdeclare @month intset @year=2008 while(@year<=2011)beginset @month=1while(@month ...