时间限制: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. MySQL的备份和还原

    MySQL的备份和还原 备份:副本    RAID1,RAID10:保证硬件损坏而不会业务中止:        DROP TABLE mydb.tb1; 备份类型:        热备份.温备份和冷备 ...

  2. The method setOnClickListener(View.OnClickListener) in the type View is not applicable

    开始学习 android 了,学习的是高明鑫老师的android视频教程(android视频教学). 学到第八讲时, 在写动态设置时报错: The method setOnClickListener( ...

  3. What is NetApp's Cluster File System?

    Data ONTAP GX: A Scalable Storage Cluster www.usenix.org/event/fast07/tech/full_papers/eisler/eisler ...

  4. [CSS] CSS Transitions: Delays and Multiple Properties

    <!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery- ...

  5. html5前端开发笔记-个人中心

    简单的css自适应 PC端 *** 移动端 *** ) *** 一开始的想法就是模仿手机APP 的页面进行布局,首先得有个头部,然后是主题部分,然后加上2个按钮,分别是编辑和退出登录.先布出基本结构. ...

  6. 企业qq代码,工作中用到的

    <div id="xixi" onmouseover="toBig()" style="top: 120px; left: 0; positio ...

  7. Git应用于Android项目的入门知识:我的理解

    Git应用于Android项目的基本知识.     常常将git,repo和gerrit三种工具配合起来使用,使Android开发中的部分工作自动化.并适应敏捷项目管理的需要.     repo是Go ...

  8. [uva11916] Emoogle Grid (离散对数)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud  Emoogle Grid  You have to color an MxN ( ...

  9. (原)不明白JNI指针调用顺序

    很不明白JNI里面获取指针的顺序(可能这样描述不太恰当吧). 下面按照传入指针的顺序的代码一跑就崩溃.如下: JNIEXPORT jint JNICALL Java_com_example_X_XX_ ...

  10. PK投票效果

    /** *createTime:2015-07-21 *updateTime:2015-06-22 *author:刘俊 *Description:PK投票 *phone:13469119119 ** ...