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: ...
随机推荐
- APlayer 媒体播放引擎
APlayer媒体播放引擎 Windows平台的播放内核 封闭式 DirectShow 架构,不受系统解码环境干扰 全媒体文件格式支持 丰富的媒体文件传输协议(http/https/ftp/mms/r ...
- Linux 下在后台运行进程:nohup,setsid,& 以及 tmux
参考: Linux 技巧:让进程在后台可靠运行的几种方法 ssh 登录了远程服务器时,如果在前台运行耗时较长的任务, 当 ssh 掉线或关闭窗口时会导致命令停止运行. hup 与 nohup 当用户注 ...
- spring boot 整合 RabbitMQ 错误
1.错误 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.spr ...
- Django报错[WinError 123] 文件名、目录名或卷标语法不正确。: '<frozen importlib._bootstrap
当你在项目文件中删除app对应的文件 却没有在项目url中删除之前配置的路径 也没有删除setting中配置的app 那么就会报错[WinError 123] 文件名.目录名或卷标语法不正确.: '& ...
- vue --》watch 深度监听的优化。
话不多说,直接上代码,注释很清楚 <template> <div> <input type="text" v-model="value&qu ...
- js提交图片转换为base64
$("#picAjax").change(function () { var strs = ""; var file = $("#picAjax&qu ...
- bash shell for循环
1 同c一样用四个空格进行缩进 2 每行一条语句,不用分号 3 不用大括号标识代码块,但是要用do/done来标识代码块 4 用双小括号,类似于c的for进行编码 for ((i=1; i<=1 ...
- git 中添加用户名和密码
git 中添加用户名和密码:https://blog.csdn.net/qq_28602957/article/details/52154384 在使用git时,如果用的是HTTPS的方式,则每次提交 ...
- Dom选择器使用与调试记录
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- jenkins使用记录转自https://my.oschina.net/sanpeterguo/blog/197931
摘要: jenkins(持续集成开源工具)提供了丰富的api接口,基本上所有的操作都可以使用curl来从后台调度,包括:创建项目,禁用项目,启用项目,获取项目描述,获取配置文件,普通触发,scm触发, ...