分形街道

我干,这个毒瘤。

想起来就头痛。

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

说一下题目大意吧。

每当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. Js中instanceof 的用法

    在 JavaScript 中,判断一个变量的类型尝尝会用 typeof 运算符,在使用 typeof 运算符时采用引用类型存储值会出现一个问题,无论引用的是什么类型的对象,它都返回 “object”. ...

  2. JS对象、基本类型和字面量的区别

    字面值: var str1='this is a simple string'; var num1=1.45; var answer1=true; 基本类型: var str2=String('thi ...

  3. 老男孩python学习自修第二十三天【多线程】

    1. 线程的创建与运行 #!/usr/bin/env python # _*_ coding:UTF-8 _*_ from threading import Thread def foo(param1 ...

  4. SQL字段类型bit 查询时注意

    sql 查询时  字段=1 或 字段=0 c# 里也是

  5. Essential Phone刷机教程

    安装fastboot驱动(Essential-PH1-WindowsDrivers) 下载ADB刷机指令工具:platform-tools(ADB): 进入开发者选项,打开 USB 调试,OEM解锁选 ...

  6. Detected problems with API compatibility(visit g.co/dev/appcompat for more info)

    应用开启了debug模式导致Android 9提示如此,使用release模式即可解决.

  7. group by具有去重的功能

    group by具有去重的功能

  8. React Router 4.0 基本使用

    路由的概念,起初来源于服务端,就是当浏览器访问一个网站的不同页面时,服务端能够正确的返回页面的内容.当访问首页时,它能返回首页的内容,访问关于我们页面时,返回关于我们的内容.可以看到路由就是一种控制和 ...

  9. ubuntu18.04系统下用devstack安装openstack(最新版)

    ubuntu18.04系统下用devstack安装openstack(最新版) 2018年12月14日 16:34:14 Cherls 阅读数:427   前期准备: 安装git,升级pip,其他 s ...

  10. linux-内核参数优化参考指标

    民间最全的Linux系统内核参数调优说   相信做运维的同仁,进行运维环境初建时,必须要考虑到操作系统内核参数的优化问题,本人经历数次的运维环境重建后,决定要自行收集一份比较完善的系统内核参数优化说明 ...