分形街道

我干,这个毒瘤。

想起来就头痛。

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

说一下题目大意吧。

每当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. laravel 循环中子元素使用&符号嵌入到父级,经典版

    /**ajax 获取企业名称 * * @param Request $request * * @return \Illuminate\Http\JsonResponse * @author lxw * ...

  2. ArrayList性能短板深入分析

    ArrayList的数据结构主体是Object[]数组,数组对象在内存的位置是成块成块的. 1.对数组进行非尾部修改,会引发System.arrayCopy()行为.这就需要对后半部要移动的对象进行内 ...

  3. 使用python库xlsxwriter库来输出各种xlsx文件

    功能性的文章直接用几个最简单的实现表达: xlsxwriter库的核心就是其Workbook对象. 创建一个指定名字的xlsx文件: import xlsxwriter filename = '/Us ...

  4. python学习笔记(5)-基本数据类型-字符串类型及操作

    一.字符串 字符串由一对单引号或者双引号表示,如”abc“,‘中国’,字符串是字符的有序序列,可以对其中的字符进行索引.字符串也可以用三单引号或三双引号表示,可以表示多行字符串,一对单引号或双引号仅表 ...

  5. sqlmap-学习1 配置环境

    sqlmap是一款非常强大的开源sql自动化注入工具,可以用来检测和利用sql注入漏洞.它由python语言开发而成,因此运行需要安装python环境 1 安装 python (https://www ...

  6. 十、docker扩展

    一.memcached docker pull memcached docker run --name my-memcache -d -p 11211:11211 memcached telnet 1 ...

  7. Python——Menu控件

    一.参数说明: tearoff  :分窗,0为在原窗,1为点击分为两个窗口 bg,fg  : 背景,前景 borderwidth: 边框宽度 font :  字体 activebackgound   ...

  8. Vue单文件组件

    前面的话 本文将详细介绍Vue单文件组件 概述 在很多 Vue 项目中,使用 Vue.component 来定义全局组件,紧接着用 new Vue({ el: '#container '}) 在每个页 ...

  9. c++ string去除首尾 空格、\n、\r、\t

    string s = " test "; size_t n = s.find_last_not_of(" \r\n\t"); if (n != string:: ...

  10. UVA 690 Pipeline Scheduling

    https://vjudge.net/problem/UVA-690 题目 你有一台包含5个工作单元的计算机,还有10个完全相同的程序需要执行.每个程序需要$n(n<20)$个时间片来执行,可以 ...