时间限制: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 找出计算的规律即可
 #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
#include <stack>
using namespace std;
int dirx[]={,,-,};
int diry[]={-,,,};
#define PI acos(-1.0)
#define max(a,b) (a) > (b) ? (a) : (b)
#define min(a,b) (a) < (b) ? (a) : (b)
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 1000000
#define inf 1e12
double n;
int num[]; int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%lf",&n);
int i;
double x=;
double y=0.5;
for(i=;;i++){
if(x>=n){
break;
}
x=x+y/2.0;
y/=2.0;
}
int w=i;
if(x==n){
printf("-1\n");
}
else{
int ans=;
for(int i=;i<w;i++){
ans+=;
}
printf("%d\n",ans);
}
}
return ;
}

hihoCoder #1234 : Fractal(数学简单题)的更多相关文章

  1. hihoCoder 1234 fractal

    #1234 : Fractal 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 This is the logo of PKUACM 2016. More specific ...

  2. [CF1538G] Gift Set (数学简单题)

    题面 相信英文题面也很好理解 有 x \tt x x 个红糖, y \tt y y 个蓝糖.每一个礼包里面要么有 a \tt a a 个红糖+ b \tt b b 个蓝糖,要么是 a \tt a a ...

  3. acm.njupt 1001-1026 简单题

    点击可展开上面目录 Acm.njupt 1001-1026简单题 第一页许多是简单题,每题拿出来说说,没有必要,也说不了什么. 直接贴上AC的代码.初学者一题题做,看看别人的AC代码,寻找自己的问题. ...

  4. PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记

    PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...

  5. 天哪!毫无思绪!令人感到恐惧的数学(水题?)(TOWQs)

    这道题的题目描述灰常简单,第一眼看以为是一道十分水的题目: 但是!!!(我仔细一看也没有发现这背后隐藏着可怕的真相~) 下面给出题目描述: 给出一个整数x,你可以对x进行两种操作.1.将x变成4x+3 ...

  6. BZOJ 2683: 简单题

    2683: 简单题 Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 913  Solved: 379[Submit][Status][Discuss] ...

  7. 【BZOJ-1176&2683】Mokia&简单题 CDQ分治

    1176: [Balkan2007]Mokia Time Limit: 30 Sec  Memory Limit: 162 MBSubmit: 1854  Solved: 821[Submit][St ...

  8. Bzoj4066 简单题

    Time Limit: 50 Sec  Memory Limit: 20 MBSubmit: 2185  Solved: 581 Description 你有一个N*N的棋盘,每个格子内有一个整数,初 ...

  9. Bzoj2683 简单题

    Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 1071  Solved: 428 Description 你有一个N*N的棋盘,每个格子内有一个整数, ...

随机推荐

  1. Hive 9、Hive 在表中添加正则匹配

    在Hive中还有一项比较好用的功能,也是非常重要的功能:在建表的时候可以不指定表的行.字段.列的分隔方式,通过给表指定一段正则表达式,让Hive自动去匹配: 1.创建表 CREATE TABLE ap ...

  2. Hibernate框架增删改查测试类归为一个类

    package cn.happy.test; import org.hibernate.Session; import org.hibernate.SessionFactory; import org ...

  3. Android UI布局之FrameLayout

    一个FrameLayout对象就好比一块屏幕上提前预定好的空白区域.然后能够填充一些元素到里边.例如说一张图片等.须要注意的是,全部的元素都被放置在FrameLayout区域最左边上的区域.并且无法为 ...

  4. ZOJ Goldbach 2013年长沙赛区网络赛

    迟到了一天的AC.... 思路: 先把单个素数 或着 两个素数能组成的情况预处理一下,然后对于给出的 n,拿第三个素数去和两个素数的情况匹配,最后要注意去重. 详情见代码. 因为手残少敲了一个 els ...

  5. 域名解析 URL转发

    URL转发 转发功能:如果您没有一台独立的服务器(也就是没有一个独立的IP地址)或者您还有一个域名B,您想访问A域名时访问到B域名的内容,这时您就可以通过URL转发来实现.url转发可以转发到某一个目 ...

  6. 使用xtrabakcup 备份inodb数据库

    1,获取yum源 rpm -ivh http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1- ...

  7. 面试前的准备---C#知识点回顾----02

    经过昨天大量的简历投递,今天陆续收到面试邀约,明日准备大战一场,是死是活一试便知 1.数据库的范式 这算入门问题了吧,但凡是个数据库类的,都得问吧, 但我们在回答的时候开始背书啦 第一范式(1NF)无 ...

  8. Windows - 远程桌面无证书

    可以从命令行启动远程桌面,输入:mstsc /v:地址:端口 /admin

  9. Android开发:shape和selector和layer-list的(详细说明)

    http://blog.csdn.net/brokge/article/details/9713041

  10. T4模板_根据DB生成实体类

    为了减少重复劳动,可以通过T4读取数据库表结构,生成实体类,用下面的实例测试了一下 1.首先创建一个项目,并添加文本模板: 2.添加 文本模板: 3.向T4文本模板文件添加代码: <#@ tem ...