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 ...
随机推荐
- 【学亮IT手记】angularJS+select2多选下拉框实例
永远保持对大部分知识的好奇心,学习从不枯燥,也没有被逼学习一说,乐此不疲才是该有的心态和境界!!! 引入相关js库: html部分代码: angularJS定义数据源变量:
- javaScript中闭包的工作原理
一.什么是闭包? 官方”的解释是:闭包是一个拥有许多变量和绑定了这些变量的环境的表达式(通常是一个函数),因而这些变量也是该表达式的一部分.相信很少有人能直接看懂这句话,因为他描述的太学术.其实这句话 ...
- jQuery 事件 - triggerHandler() 方法
定义和用法 triggerHandler() 方法触发被选元素的指定事件类型.但不会执行浏览器默认动作,也不会产生事件冒泡. triggerHandler() 方法与 trigger() 方法类似.不 ...
- 小程序获取当前页面URL
var pages = getCurrentPages() //获取加载的页面 var currentPage = pages[pages.length-1] //获取当前页面的对象 var url ...
- 简单JQuery+AJAX+Servlet的计算器实现
index.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pag ...
- WPF当属性值改变时利用PropertyChanged事件来加载动画
在我们的程序中,有时我们需要当绑定到UI界面上的属性值发生变化从而引起数据更新的时候能够加载一些动画,从而使数据更新的效果更佳绚丽,在我们的程序中尽量将动画作为一种资源放在xaml中,而不是在后台中通 ...
- chrome版本下载
chrome 下载:https://www.chromedownloads.net/chrome64win/ chromedriver下载:http://chromedriver.storage.go ...
- 在delphi中生成GUID
什么是 GUID ? 全球唯一标识符 (GUID) 是一个字母数字标识符,用于指示产品的唯一性安装.在许多流行软件应用程序(例如 Web 浏览器和媒体播放器)中,都使用 GUID. GUID 的格式为 ...
- Eclipse:报错Failed to read artifact descriptor for org.springframework.boot:spring-boot-autoconfigure:jar:2.1.2.
导入SVN下载的MAVEN项目时springboot报错: pom.xml文件报错 Failed to read artifact descriptor for org.springframework ...
- Y7000联想拯救者gtx1050Ti安装cuda9.0
安装cuda经常会遇到安装失败的问题,原因大部分都是由于驱动不一致引起的,接下来我们分两步讲解 1. 安装驱动失败 原因:nvidia官网提供的驱动都是通用的,针对特殊设备可能出现不兼容问题,方法很简 ...