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 ...
随机推荐
- CUDA ---- Memory Model
Memory kernel性能高低是不能单纯的从warp的执行上来解释的.比如之前博文涉及到的,将block的维度设置为warp大小的一半会导致load efficiency降低,这个问题无法用war ...
- L209
China's Chang'e-4 probe entered a planned orbit Sunday morning // to prepare for the first-ever soft ...
- 掌握 javascript 核心概念 最好的教程 系列 之一
链接 新链接 函数优先, 在扫描创建变量阶段, 会先收集函数, 如果前面有同名函数或者变量, 这个新函数会覆盖前面同名的: 而如果这时候是变量, 则不能去覆盖前面已有的值. function test ...
- 深度分析:Android中Mms设置页面更改短信中心号码流程
相关控件初始化方法:showSmscPref private void showSmscPref() { int count = MSimTelephonyManager.getDef ...
- 2.2 linux中的信号分析
信号: 信号是UNIX系统响应某些状况而产生的事件,进程在接收到信号时会采取相应的行动. 信号是因为某些错误条件而产生的,比如内存段冲突.浮点处理器错误或者非法指令等. 信号是在软件层次上对中断的一种 ...
- CentOS7安装OpenStack(Rocky版)-07.安装horizon服务组件(控制节点dashboard)
在上一篇文章分享了neutron网络服务的安装配置,本文分享openstack的horizon(dashboard)web界面管理服务,方便在浏览器操作 ---------------------- ...
- TJU Problem 1065 Factorial
注意数据范围,十位数以上就可以考虑long long 了,断点调试也十分重要. 原题: 1065. Factorial Time Limit: 1.0 Seconds Memory Limit ...
- 共享仓库,远程仓库,多人协作,github操作
1.共享仓库: 创建共享仓库 1.创建文件夹 mkdir file 2.设置文件夹属主 chown tarena:tarena file 3.将该文件夹设置为可共享的git仓库 cd file git ...
- 初识Tarjan算法
#include<bits/stdc++.h> using namespace std; ; ;//强连通分量的个数 int stk[maxn];//暂时存放遍历过的点,在遇到low[x] ...
- 给div加滚动条
<div style="width:175px;height:100px;background:white;overflow:scroll;"> <span> ...