Fractal
Fractal
描述

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的更多相关文章
- 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 ...
- 分形树Fractal tree介绍——具体如何结合TokuDB还没有太懂,先记住其和LSM都是一样的适合写密集
在目前的Mysql数据库中,使用最广泛的是innodb存储引擎.innodb确实是个很不错的存储引擎,就连高性能Mysql里都说了,如果不是有什么很特别的要求,innodb就是最好的选择.当然,这偏文 ...
- C - Fractal(3.4.1)
Description A fractal is an object or quantity that displays self-similarity, in a somewhat technica ...
- 2015北京网络赛 H题 Fractal 找规律
Fractal Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/acmicpc2015beijingo ...
- Fractal(递归,好题)
Fractal Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8341 Accepted: 3965 Descripti ...
- - Fractal(3.4.1)
C - Fractal(3.4.1) Time Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64u Su ...
- Codeforces 36B - Fractal
36B - Fractal 思路:分形 代码: #include<bits/stdc++.h> using namespace std; #define ll long long #def ...
- ( 递归 )Fractal -- POJ -- 2083
http://poj.org/problem?id=2083 Fractal Time Limit: 1000MS Memory Limit: 30000K Total Submissions: ...
随机推荐
- Week13 - 376. Wiggle Subsequence
Week13 - 376. Wiggle Subsequence A sequence of numbers is called a wiggle sequence if the difference ...
- JDK+Tomcat+Eclipse环境搭建过程记录
这学期选了一门公选课叫网络开发工具与技术,主要学习用JSP语言构建网站.在配置环境的过程中遇到不少的坑,于是记录下来,希望能帮到大家. 系统环境:Win10 JDK版本:8u121, JAVA版本1. ...
- c#处理bin文件
1. fs.Position 写入的位置,从哪个位置开始写 fs.Write(byte1,0,byte1.Length); byte1写入的byte[], 写入内容从第几位开始取,length取多长 ...
- hbase迁移快照ExportSnapshot时遇到的错
1.Cannot allocate memory 报错信息: Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x ...
- Log4net使用(二)
转:http://www.cnblogs.com/basilwang/archive/2006/06/09/421868.html Log4net同时按照日期和大小生成RollingFile和访问Sy ...
- Node.js实战10:“流”是Node.js最强大的功能之一。
流是Nodejs的高级应用,掌握流的使用,才能真正胜任NodeJS开发. Nodejs中,流是基于事件的API,用于管理和处理数据,而且效率很好! 什么是流? 流是一个抽象接口,Node 中有很多对象 ...
- 2019春第十一周作业Compile Summarize
这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 这里 我在这个课程的目标是 能按自己的想法解出题目 这个作业在那个具体方面帮助我实现目标 能朝着软件工程师方向发展 参考文献与网址 C语言 ...
- idea 社区版本创建javaweb项目 使用tomcat
1.创建maven webapp项目 2.pom文件添加依赖及tomcat7-maven-plugin插件 <dependencies> <dependency> <g ...
- selenium的常见异常
selenium的常见异常 Exceptions(异常)Python 自带的异常,所有异常的基类. 异常: selenium.common.exceptions.ElementNotSelectabl ...
- 问题 F: 超超的自闭意思
问题 F: 超超的自闭意思 时间限制: 1 Sec 内存限制: 128 MB提交: 80 解决: 10[提交] [状态] [命题人:jsu_admin] 题目描述 质数定义为在大于1的自然数中,除 ...