Fractal

时间限制:1000ms
单点时限:1000ms
内存限制:256MB

描述

This is the logo of PKUACM 2016. More specifically, the logo is generated as follows:

1. Put four points A0(0,0), B0(0,1), C0(1,1), D0(1,0) on a cartesian coordinate system.

2. Link A0B0, B0C0, C0D0, D0A0 separately, forming square A0B0C0D0.

3. Assume we have already generated square AiBiCiDi, then square Ai+1Bi+1Ci+1Di+1 is generated by linking the midpoints of AiBi, BiCi, CiDi and DiAi successively.

4. Repeat step three 1000 times.

Now the designer decides to add a vertical line x=k to this logo( 0<= k < 0.5, and for k, there will be at most 8 digits after the decimal point). He wants to know the number of common points between the new line and the original logo.

输入

In the first line there’s an integer T( T < 10,000), indicating the number of test cases.

Then T lines follow, each describing a test case. Each line contains an float number k, meaning that you should calculate the number of common points between line x = k and the logo.

输出

For each test case, print a line containing one integer indicating the answer. If there are infinity common points, print -1.

样例输入
3
0.375
0.001
0.478
样例输出
-1
4
20
题意: 在一个坐标系里有如图图像,问当直线x=k与图像交点有多少,如果是无数的话输出-1
 #include <iostream>
#include<cstdio>
#include<cstring>
#include<math.h>
#include<algorithm> using namespace std; #define N 1100
#define INF 0x3f3f3f3f int main()
{
int t;
double x;
scanf("%d", &t);
double c = 0.5;
double a[N] = {};
int b[N] = {};
for(int i = ; i < ; i++)
{
a[i] = c/ + a[i-];
b[i] = b[i-] + ;
c /= ;
}
while(t--)
{
scanf("%lf", &x);
for(int i = ; i < ; i++)
{
if(fabs(a[i]-x) < 0.00000000000001)
{
printf("-1\n");
break;
}
else if(x < a[i])
{
printf("%d\n", b[i]);
break;
}
}
}
return ;
}

Fractal的更多相关文章

  1. Mysql存储引擎之TokuDB以及它的数据结构Fractal tree(分形树)

    在目前的Mysql数据库中,使用最广泛的是innodb存储引擎.innodb确实是个很不错的存储引擎,就连高性能Mysql里都说了,如果不是有什么很特别的要求,innodb就是最好的选择.当然,这偏文 ...

  2. POJ 2083 Fractal

    Fractal Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6646   Accepted: 3297 Descripti ...

  3. POJ1941 The Sierpinski Fractal

    Description Consider a regular triangular area, divide it into four equal triangles of half height a ...

  4. 分形树Fractal tree介绍——具体如何结合TokuDB还没有太懂,先记住其和LSM都是一样的适合写密集

    在目前的Mysql数据库中,使用最广泛的是innodb存储引擎.innodb确实是个很不错的存储引擎,就连高性能Mysql里都说了,如果不是有什么很特别的要求,innodb就是最好的选择.当然,这偏文 ...

  5. C - Fractal(3.4.1)

    Description A fractal is an object or quantity that displays self-similarity, in a somewhat technica ...

  6. 2015北京网络赛 H题 Fractal 找规律

    Fractal Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc2015beijingo ...

  7. Fractal(递归,好题)

    Fractal Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 8341   Accepted: 3965 Descripti ...

  8. - Fractal(3.4.1)

    C - Fractal(3.4.1) Time Limit:1000MS    Memory Limit:30000KB    64bit IO Format:%I64d & %I64u Su ...

  9. Codeforces 36B - Fractal

    36B - Fractal 思路:分形 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #def ...

  10. ( 递归 )Fractal -- POJ -- 2083

    http://poj.org/problem?id=2083 Fractal Time Limit: 1000MS   Memory Limit: 30000K Total Submissions:  ...

随机推荐

  1. Python学习笔记(20)-文件和文件夹的移动、复制、删除、重命名

    一,概述 python中对文件和文件夹进行移动.复制.删除.重命名,主要依赖os模块和shutil模块,要死记硬背这两个模块的方法还是比较困难的,可以用一个例子集中演示文件的移动.复制.删除.重命名, ...

  2. 剑指offer--day01

    1.1题目:二维数组中的查找:在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断 ...

  3. 应用安全 - 代码审计 - PHP

    RCE RCE函数 eval.preg_replace + /e模式.assertJavascript:evalVbscript: Execute.EvalPython:exec <?php i ...

  4. 为什么说 Babel 将推动 JavaScript 的发展【转】

    Babel是一个转换编译器,它能将 ES6 转换成可以在浏览器中运行的代码.Babel 由来自澳大利亚的开发者Sebastian McKenzie创建.他的目标是使 Babel 可以处理 ES6 的所 ...

  5. oracle--批量删除部分表,将某一列拼接成字符串

    1.查询要批量删除的表 SELECT * FROM USER_TABLES SELECT 'DROP '||'TABLE ' || TABLE_NAME ||' ;' ,1 FROM USER_TAB ...

  6. python基础-8迭代器(iter)和生成器(yield)

    一 生成器 从Python2.2起,生成器提供了一种简洁的方式帮助返回列表元素的函数来完成简单和有效的代码. 它基于yield指令,允许停止函数并立即返回结果.此函数保存其执行上下文,如果需要,可立即 ...

  7. [Python3 填坑] 016 对 __getattr__ 和 __setattr__ 举例

    目录 1. print( 坑的信息 ) 2. 开始填坑 2.1 __getattr__ 2.2 __setattr__ 1. print( 坑的信息 ) 挖坑时间:2019/04/07 明细 坑的编码 ...

  8. POJ-2456.Aggressivecows.(二分求解最大化最小值)

    本题大意:在坐标轴上有n个点,现在打算在这n个点上建立c个牛棚,由于牛对厂主的分配方式表示很不满意,它很暴躁,所以它会攻击离它很近的牛来获得快感,这件事让厂主大大知道了,他怎么可能容忍?所以他决定有策 ...

  9. 【洛谷p1970】花匠

    莫得致敬lz谢谢.lz的题解是优秀的题解谢谢! 看算法标签 但是我并不会DP的思路,用一个很神奇的码量超级少的代码(虽然我码了超多),然后其实这个数据可以看做是一个函数嘛对吧:(比如说样例) 那么要注 ...

  10. [2019杭电多校第六场][hdu6641]TDL

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6641 题意为求出最小的n,满足(f(n,m)-n)^n=k,其中f(n,m)为第m大的x,其中x满足g ...