bzoj2263: Pku3889 Fractal Streets

给出两点编号,求如图所示的图中两点间欧氏距离*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的更多相关文章
- POJ 3889 Fractal Streets(逼近模拟)
$ POJ~3889~Fractal~Streets $(模拟) $ solution: $ 这是一道淳朴的模拟题,最近发现这种题目总是可以用逼近法,就再来练练手吧. 首先对于每个编号我们可以用逼近法 ...
- poj3889 fractal streets
分形街道 我干,这个毒瘤. 想起来就头痛. 首先看题就是一大难题...... 说一下题目大意吧. 每当n+1时,把n阶图复制为4份.2*2排好. 右边两个不动.左上顺时针旋转90°,左下逆时针旋转90 ...
- 题解 Fractal Streets
题目链接 参考博客 #include<cstdio> #include<math.h> #include<utility>//pair using namespac ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- POJ3889Fractal Streets
Fractal Streets Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 445 Accepted: 162 Des ...
- 0x03
指数级枚举:1到n任意选取的所有方案数: #include<bits/stdc++.h> using namespace std; int n,a[1100],vis[1100],cnt, ...
- Mysql存储引擎之TokuDB以及它的数据结构Fractal tree(分形树)
在目前的Mysql数据库中,使用最广泛的是innodb存储引擎.innodb确实是个很不错的存储引擎,就连高性能Mysql里都说了,如果不是有什么很特别的要求,innodb就是最好的选择.当然,这偏文 ...
- POJ 2083 Fractal
Fractal Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6646 Accepted: 3297 Descripti ...
- POJ1941 The Sierpinski Fractal
Description Consider a regular triangular area, divide it into four equal triangles of half height a ...
随机推荐
- [译].Net 4.5 的五项强大新特性
本文原文:Five Great .NET Framework 4.5 Features 译者:冰河魔法师 目录 介绍 特性一:async和await 特性二:Zip压缩 特性三:正则表达式执行超时 特 ...
- CUDA ---- Memory Model
Memory kernel性能高低是不能单纯的从warp的执行上来解释的.比如之前博文涉及到的,将block的维度设置为warp大小的一半会导致load efficiency降低,这个问题无法用war ...
- Flappy Bird背后的故事
更多有价值的互联网文章:晓煦分享(http://www.ihuxu.com/share) 由越南游戏工程师阮哈东(Nguyen Ha Dong)开发的Flappy Bird这款游戏,画面不算精致且看起 ...
- java.io.FileNotFoundException: antlr-2.7.7.jar (系统找不到指定的路径。)[待解决]
严重: Failed to destroy the filter named [struts2] of type [org.apache.struts2.dispatcher.ng.filter.St ...
- Redis----windows下的常用命令
1:首先下载redis.从下面地址下:https://github.com/MSOpenTech/redis/releases2:创建redis.conf文件:这是一个配置文件,指定了redis的监听 ...
- dubbo支持的注册中心
dubbo支持的注册中心 Dubbo提供的注册中心有如下几种类型可供选择: Multicast注册中心 Zookeeper注册中心 Redis注册中心 Simple注册中心 ZooKeeper是一个开 ...
- pandas 操作 excel
1. 多重 sheet Using Pandas to pd.read_excel() for multiple worksheets of the same workbook pd.read_exc ...
- mysql命令小结
MySQL 数据库常用命令 1.MySQL常用命令 create database name; 创建数据库 use databasename; 选择数据库 drop database name 直接删 ...
- QT4 交叉编译
配置 ./configure \-prefix /usr \-no-rpath \-embedded arm \-xplatform /qws/linux-arm-gnueabi-g++ \-dept ...
- 【c++基础】vector中按照Point类型某一个变量进行排序
code // sort(a.begin(), a.end(), cmpy); //subfunction bool cmpy(cv::Point const& a, cv::Point co ...