博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hihoCoder #1234 : Fractal(数学简单题)
阅读量:6376 次
发布时间:2019-06-23

本文共 2138 字,大约阅读时间需要 7 分钟。

时间限制: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.

样例输入
30.3750.0010.478
样例输出
-1420 找出计算的规律即可
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 #include
15 using namespace std;16 int dirx[]={ 0,0,-1,1};17 int diry[]={-1,1,0,0};18 #define PI acos(-1.0)19 #define max(a,b) (a) > (b) ? (a) : (b) 20 #define min(a,b) (a) < (b) ? (a) : (b)21 #define ll long long22 #define eps 1e-1023 #define MOD 100000000724 #define N 100000025 #define inf 1e1226 double n;27 int num[100000];28 29 int main()30 {31 int t;32 scanf("%d",&t);33 while(t--){34 scanf("%lf",&n);35 int i;36 double x=0;37 double y=0.5;38 for(i=0;;i++){39 if(x>=n){40 break;41 }42 x=x+y/2.0;43 y/=2.0;44 }45 int w=i;46 if(x==n){47 printf("-1\n");48 }49 else{50 int ans=0;51 for(int i=0;i
View Code

 

转载地址:http://ddtqa.baihongyu.com/

你可能感兴趣的文章
实现MySQL允许远程连接
查看>>
Java Outputstream to String
查看>>
RS232C串口通信接线方法(三线制)
查看>>
Android 自定义View属性相关细节
查看>>
type already defined error in Eclipse
查看>>
OSA 安装
查看>>
先安装.Framework然后再安装IIS,ASP.NET程序不能运行
查看>>
NPOI Excel下拉项生成设置
查看>>
360该不该拍?
查看>>
用Xib创建控制器
查看>>
oracle的sqlplus和dos的中文乱码问题
查看>>
LVS+keepalived高可用负载均衡集群部署(二)---LAMP网站服务器与LVS服务器
查看>>
Struts2之简单数据类型转换
查看>>
python 打印数字
查看>>
iptables规则的查看、添加、删除和修改
查看>>
打开网站显示输入用户名和密码
查看>>
size_t的32位和64位兼容
查看>>
HBase全分布式模式的安装和配置
查看>>
Spring 框架的设计理念与设计模式分析
查看>>
十年web老兵整理的前端视频资料
查看>>