poj3889 fractal streets
分形街道
我干,这个毒瘤。
想起来就头痛。
首先看题就是一大难题......
说一下题目大意吧。
每当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的更多相关文章
- POJ 3889 Fractal Streets(逼近模拟)
$ POJ~3889~Fractal~Streets $(模拟) $ solution: $ 这是一道淳朴的模拟题,最近发现这种题目总是可以用逼近法,就再来练练手吧. 首先对于每个编号我们可以用逼近法 ...
- bzoj2263: Pku3889 Fractal Streets
给出两点编号,求如图所示的图中两点间欧氏距离*10取整 递归处理由编号求出坐标 #include<cstdio> #include<cmath> int T,n,s,t; vo ...
- 题解 Fractal Streets
题目链接 参考博客 #include<cstdio> #include<math.h> #include<utility>//pair using namespac ...
- POJ3889Fractal Streets
Fractal Streets Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 445 Accepted: 162 Des ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- 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 ...
随机推荐
- Day 4-2 random模块
import random random.randint(1,100) # 从1到100中随机取出一个数.包含100 random.randrange(1,100) #功能和上面一样.只是不包含100 ...
- hive字符函数
- spec文件中的 %pre %post %preun %postun
转载http://meinit.nl/rpm-spec-prepostpreunpostun-argument-values RPM has 4 parts where (shell) scripts ...
- Android SDK Tools 24.3.2 Build脚本Bug
如下图版本: 在%Android_home%\tools\ant\build.xml中, 在483行附近, 少了aidl,aapt,dx, zipalign四个变量的声明. 加上就OK了. <p ...
- Nginx stream ssl
L 115 端口监听 netstat -anp | (端口名)
- python时间模块datetime
datetime模块 datetime在python中比较常用,主要用来处理时间日期,使用前先倒入datetime模块.下面总结下本人想到的几个常用功能. 1.当前时间(日期.小时.字符串时....) ...
- git 回退版本
回滚到指定的版本 git reset --hard e377f60e28c8b84158 强制提交 git push -f origin master
- Spring MVC 使用介绍(三)—— Controller接口控制器
一.概述 Controller接口类图如下,其中,BaseCommandController已从Spring 4移除 基于继承Controller接口的方式已经不推荐使用,仅供学习参考 二.基于Con ...
- LIRE图片识别搜索demo--Ubuntu开发
Ubuntu安装shadowsocks客户端/服务端教程 1.安装shadowsocks sudo apt-get update sudo apt-get install python-pip sud ...
- BZOJ5063旅游——非旋转treap
题目描述 小奇成功打开了大科学家的电脑. 大科学家打算前往n处景点旅游,他用一个序列来维护它们之间的顺序.初 始时,序列为1,2,...,n. 接着,大科学家进行m次操作来打乱顺序.每次操作有6步: ...