给出两点编号,求如图所示的图中两点间欧氏距离*10取整

递归处理由编号求出坐标

#include<cstdio>
#include<cmath>
int T,n,s,t;
void get(int n,int p,int&x,int&y){
if(!n){
x=y=;
return;
}
int D=<<n*-,L=<<n-;
int w=p/D;
get(n-,p&(D-),x,y);
if(w==){
int x0=x,y0=y;
x=y0,y=x0;
}else if(w==){
x+=L;
}else if(w==){
x+=L;
y+=L;
}else{
int x0=x,y0=y;
x=L--y0;
y=L*--x0;
}
}
int main(){
for(scanf("%d",&T);T;--T){
scanf("%d%d%d",&n,&s,&t);
int x1,y1,x2,y2;
get(n,s-,x1,y1);
get(n,t-,x2,y2);
printf("%d\n",(int)round(hypot(x1-x2,y1-y2)*));
}
return ;
}

bzoj2263: Pku3889 Fractal Streets的更多相关文章

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

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

  2. poj3889 fractal streets

    分形街道 我干,这个毒瘤. 想起来就头痛. 首先看题就是一大难题...... 说一下题目大意吧. 每当n+1时,把n阶图复制为4份.2*2排好. 右边两个不动.左上顺时针旋转90°,左下逆时针旋转90 ...

  3. 题解 Fractal Streets

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

  4. bzoj AC倒序

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

  5. POJ3889Fractal Streets

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

  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. TListBox的项目个数

    function TCustomListBox.GetCount: Integer; begin if Style in [lbVirtual, lbVirtualOwnerDraw] then Re ...

  2. pat 集合相似度

    L2-005. 集合相似度 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 给定两个整数集合,它们的相似度定义为:Nc/Nt*1 ...

  3. array_merge、array_merge_recursive

    原文:http://www.111cn.net/phper/php/61889.htm    我在php学习在使用到最多的数据合并方法就是array_merge.array_merge_recursi ...

  4. 【微信小程序推广营销】教你微信小程序SEO优化,让你的小程序快人一步抢占先机

    今年一月份上线的小程序,经过近一年的沉淀发酵,现在也进入了快速发展期. 在未来肯定会有越来越多的小程序诞生,小程序多了就需要搜索,那么如何让自己的小程序在众多的小程序中脱颖而出,这就需要小程序SEO优 ...

  5. android中传统的创建数据库

    1.在Android工程中建立一个class类,且继承与SQLiteOpenHelper. 2.然后到Mainactivity中去new一个MyOpenHelper来找到它 3.第一次创建数据库的时候 ...

  6. 2018-2019-2 20165212《网络对抗技术》Exp1 PC平台逆向破解

    2018-2019-2 20165212<网络对抗技术>Exp1  缓冲区溢出实验 实验点1:逆向及Bof基础实践 实践任务 用一个pwn1文件. 该程序正常执行流程是:main调用foo ...

  7. TP3.2整合uplodify文件上传

    HTML中:<style>#img_upload-queue{width:120px;float:left;} /*uploadify的上传进度条样式,前面的img_upload是根据上传 ...

  8. java基本数据类型和引用类型

    这些基本的数据类型是点不出东西来的 3种引用类型  类class 接口interface 数组array 第一个  : 类 Integer  Long  Boolean  Byte  Characte ...

  9. ElasticSearch 5.0 简介

    参考:http://blog.csdn.net/wzhg0508/article/details/52063676 Elasticsearch 5.0 简介(medcl微信直播实录) 大家好,非常高兴 ...

  10. leetcode:Longest Common Prefix【Python版】

    1.当strs为空,直接输出“” 2.当strs中含有“”,直接输出“” 3.strs[0]的最长长度由最短公共长度l决定(code line:15) class Solution: # @retur ...