博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Fractal
阅读量:7022 次
发布时间:2019-06-28

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

 Fractal

时间限制: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 题意: 在一个坐标系里有如图图像,问当直线x=k与图像交点有多少,如果是无数的话输出-1
1 #include 
2 #include
3 #include
4 #include
5 #include
6 7 using namespace std; 8 9 #define N 110010 #define INF 0x3f3f3f3f11 12 int main()13 {14 int t;15 double x;16 scanf("%d", &t);17 double c = 0.5;18 double a[N] = {
0};19 int b[N] = {
0};20 for(int i = 1; i < 1000; i++)21 {22 a[i] = c/2 + a[i-1];23 b[i] = b[i-1] + 4;24 c /= 2;25 }26 while(t--)27 {28 scanf("%lf", &x);29 for(int i = 0; i < 1000; i++)30 {31 if(fabs(a[i]-x) < 0.00000000000001)32 {33 printf("-1\n");34 break;35 }36 else if(x < a[i])37 {38 printf("%d\n", b[i]);39 break;40 }41 }42 }43 return 0;44 }

 

转载于:https://www.cnblogs.com/Tinamei/p/4831373.html

你可能感兴趣的文章
MySQL内存表的弊端
查看>>
使用SIMILE Timeline 将邮件“事件”可视化
查看>>
SQL:创建某一时间段内的周末日期表以及特殊处理日期表
查看>>
什么是CGI、FastCGI、PHP-CGI、PHP-FPM、Spawn-FCGI?(转)
查看>>
LindAgile.SchedulingTask~设计一个不错的任务调度组件
查看>>
恶搞之手机垃圾信息发送器 手机短信骚扰器
查看>>
mysql replication之binlog-do-db、binlog-ignore-db
查看>>
Date类型和Long类型的相互转换
查看>>
XMPP协议
查看>>
CSS:给 input 中 type="text" 设置CSS样式
查看>>
Softmax函数
查看>>
hdu4462 Scaring the Birds
查看>>
设计中的道理_6
查看>>
MFC——AfxParseURL用法
查看>>
Cocos2d-x3.2 Sprite精灵类的创建与设置
查看>>
Starting MySQL.Manager of pid-file quit without updating file.[FAILED]
查看>>
深入浅出PostgreSQL B-Tree索引结构
查看>>
PostgreSQL 如何高效解决 按任意字段分词检索的问题 - case 1
查看>>
JAVA中的CAS
查看>>
51nod 1770 数数字
查看>>