分形街道

我干,这个毒瘤。

想起来就头痛。

首先看题就是一大难题......

说一下题目大意吧。

每当n+1时,把n阶图复制为4份。2*2排好。

右边两个不动。左上顺时针旋转90°,左下逆时针旋转90°

求n阶图中a和b的直线距离。

考虑递归解决:这TM怎么递归啊!!!

仿佛可以......我一开始带了十多个变量,后来缩减到了8个,自觉很ok了

标答带了两个变量。我:................

我们不管标答,继续钻研中国特色射惠主义。

然后我以为每次旋转完之后内部遍历顺序不会变,于是自信WA了。

仔细钻研:发现方向朝向一样的时候,遍历顺序是一样的。我:什么垃圾题。

分16种情况大力讨论A了。

 /**
poj 3889
*/
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
// 1 0 3 2 3 2 1 0 1 0 1
// 0 k 2 1 2 3 0
// 3 1 2 1 0 3 0 3 2 3 2
void solve(LL& x, LL& y, LL T, LL a, int n, int k, LL now_x, LL now_y)
{
//printf("solve: T:%I64d a:%I64d n:%d k:%d now_x:%I64d now_y:%I64d ", T, a, n, k, now_x, now_y);
if(n==)
{
//printf("\n");
x = now_x;
y = now_y;
return;
}
LL len = 1ll << (n - );
LL s = len * len;
int now_area = (T - a) / s, now_k, area;
//printf("now_area:%d\n", now_area);
LL d[][];
d[][] = now_x;
d[][] = now_y;
d[][] = now_x;
d[][] = now_y + len;
d[][] = now_x + len;
d[][] = now_y + len;
d[][] = now_x + len;
d[][] = now_y; /*
3
1 1 2
2 1 16
3 4 33 */
if(k == ) {
if(now_area == ) {
area = ;
now_k = ;
}
else if(now_area == ) {
area = ;
now_k = ;
}
else if(now_area == ) {
area = ;
now_k = ;
}
else {
area = ;
now_k = ;
}
}
else if(k == ) {
if(now_area == ) {
area = ;
now_k = ;
}
else if(now_area == ) {
area = ;
now_k = ;
}
else if(now_area == ) {
area = ;
now_k = ;
}
else {
area = ;
now_k = ;
}
}
else if(k == ) {
if(now_area == ) {
area = ;
now_k = ;
}
else if(now_area == ) {
area = ;
now_k = ;
}
else if(now_area == ) {
area = ;
now_k = ;
}
else {
area = ;
now_k = ;
}
}
else {
if(now_area == ) {
area = ;
now_k = ;
}
else if(now_area == ) {
area = ;
now_k = ;
}
else if(now_area == ) {
area = ;
now_k = ;
}
else {
area = ;
now_k = ;
}
}
solve(x, y, T, a + now_area * s, n - , now_k, d[area][], d[area][]);
return;
}
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int n;
LL a, b;
scanf("%d%I64d%I64d", &n, &a, &b);
LL x=,y=;
solve(x, y, a, , n, , , );
LL xx=,yy=;
solve(xx, yy, b, , n, , , );
//printf("%I64d %I64d \n", x, y);
//printf("%I64d %I64d \n", xx, yy);
printf("%.0lf\n", * sqrt((double)((xx - x) * (xx - x) + (yy - y) * (yy - y))));
}
return ;
}

AC代码

poj3889 fractal streets的更多相关文章

  1. POJ 3889 Fractal Streets(逼近模拟)

    $ POJ~3889~Fractal~Streets $(模拟) $ solution: $ 这是一道淳朴的模拟题,最近发现这种题目总是可以用逼近法,就再来练练手吧. 首先对于每个编号我们可以用逼近法 ...

  2. bzoj2263: Pku3889 Fractal Streets

    给出两点编号,求如图所示的图中两点间欧氏距离*10取整 递归处理由编号求出坐标 #include<cstdio> #include<cmath> int T,n,s,t; vo ...

  3. 题解 Fractal Streets

    题目链接 参考博客 #include<cstdio> #include<math.h> #include<utility>//pair using namespac ...

  4. POJ3889Fractal Streets

    Fractal Streets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 445   Accepted: 162 Des ...

  5. bzoj AC倒序

    Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...

  6. 0x03

    指数级枚举:1到n任意选取的所有方案数: #include<bits/stdc++.h> using namespace std; int n,a[1100],vis[1100],cnt, ...

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

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

  8. POJ 2083 Fractal

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

  9. POJ1941 The Sierpinski Fractal

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

随机推荐

  1. hihoCoder1033 交错和 数位DP

    题目:交错和 链接:http://hihocoder.com/problemset/problem/1033# 题意:对于一个十进制整数x,令a0.a1.a2.....an是x从高位到低位的数位,定义 ...

  2. Java 多线程概述

    几乎所有的操作系统都支持同时运行多个任务,一 个任务通常就是一个程序,每个运行中的程序就是一个进程.当一个程序运行时,内部可能包含了多个顺序执行流,每个顺序执行流就是一个线程. 线程和进程 几乎所有的 ...

  3. java 中Excel的导入导出

    部分转发原作者https://www.cnblogs.com/qdhxhz/p/8137282.html雨点的名字  的内容 java代码中的导入导出 首先在d盘创建一个xlsx文件,然后再进行一系列 ...

  4. Hbase的作用

    实时动态增加列 多版本的意思为多个用户地址,多个用户信息,多个用户号码

  5. IBM rational rose画时序图软件破解安装

    上边这个链接是开头的安装步骤,照着链接中的步骤安装完之后,接下来看下边. 1.然后安装完成打开软件“IBM Rational License Keyadministrator”.出现下图:选中第二项“ ...

  6. 开发中遇到的css兼容问题

    1. overflow: scroll(平台兼容) 在Mac中的Chrome浏览器中,内容不超过容器时不会出现滚动条: 在Wins中的Chorme浏览器中,内容不超过容器时也会出现滚动条. 解决方法: ...

  7. vue自定义组件及传值

    1.使用 Vue.component() 方法注册组件 2.使用 props 属性传递参数 v-for="item in items": 遍历 Vue 实例中定义的名为 items ...

  8. EChart.js 笔记二

    交互组件 Echart.js 中交互组件比较多.例如: legend(图例).title(标题组件).visualMap(视觉映射组件).dataZoom(数据缩放组件).timeline(时间线组件 ...

  9. CSS遮罩效果和毛玻璃效果

    前面的话 本文将详细介绍CSS遮罩效果和毛玻璃效果 遮罩效果 普通遮罩 一般地,处理全屏遮罩的方法是使用额外标签 <style>.overlay{ position:fixed; top: ...

  10. 在web-inf外面 使用的是绝对路径进行访问 “/”表示访问文件夹 一层一层方式 我们在windos下访问文件夹也是一层一层的访问