B - Light Bulb

Compared to wildleopard's wealthiness, his brother mildleopard is rather poor. His house is narrow and he has only one light bulb in his house. Every night, he is wandering in his incommodious house, thinking of how to earn more money. One day, he found that the length of his shadow was changing from time to time while walking between the light bulb and the wall of his house. A sudden thought ran through his mind and he wanted to know the maximum length of his shadow.

Input

The first line of the input contains an integer T (T <= 100), indicating the number of cases.

Each test case contains three real numbers H, h and D in one line.H is the height of the light bulb while h is the height of mildleopard.D is distance between the light bulb and the wall. All numbers are in range from 10-2 to 103, both inclusive, andH - h >= 10-2.

<b< dd="">

Output

For each test case, output the maximum length of mildleopard's shadow in one line, accurate up to three decimal places..

<b< dd="">

Sample Input

3
2 1 0.5
2 0.5 3
4 3 4

<b< dd="">

Sample Output

1.000
0.750
4.000 
火柴人从灯泡下向D前进,影子开始会慢慢变长,而当影子的落点到达D时,如果继续向D前进,影子也许会继续变长,也许会变短,所以火柴人前进的距离与影子的长度的函数是个开口向下的凸函数(当有凹凸时可以试试三分),因此比较适合三分法
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
int main()
{

    int T;
    //freopen("1.txt","r",stdin);
    scanf("%d",&T);
    while (T--)
    {
        double H,h,D,t1,t2,l,r,mid,midd;
        scanf("%lf%lf%lf",&H,&h,&D);
        l=(H - h) * D / H,r=D;
        while(r-l>=1e-8)
        {
            mid=(r+l)/2,midd=(mid+r)/2;
            t1=D - mid + H - (H - h) * D / mid;
            t2=D - midd + H - (H - h) * D / midd;

            if(t1<t2)l=mid;
            else r=midd;
        }
        printf("%.3lf\n",t2);
    }
    return 0;
}

任务 3-6:数据库系统维护与应用 为了更好地管理工厂,请根据以下要求完成 SQL Server 数据库 操作。 任务要求: 1.创建一张名为 iot_devices 的表,如图所示。 2.创建一张名为 iot_data 的表,如图所示。 device_id 主键,自增 device_name 设备名称,非空 device_type 设备类型 location 设备位置 status 设备状态 last_update 最后更新时间 iot_devices data_id 主键,自增 device_name timestamp value iot_data 3.编写 SQL 语句,向 iot_devices 表插入以下设备信息。 4.编写 SQL 语句,向 iot_data 表插入以下数据。 5.编写 SQL 语句,查询所有在线的设备名称及其位置。 6.编写 SQL 语句,查询设备 TempSensor_001 的所有数据,按数 17 值从小到大排列。 7.编写 SQL 语句,将设备 LightBulb_002 的状态更新为“在线”。 device_name device_type location status TempSensor_001 温度传感器 工厂 B 区 在线 LightBulb_002 智能灯泡 工厂 C 区 离线 HumidSensor_003 湿度传感器 工厂 A 区 在线 iot_devices device_id value 1 25.3 1 26.1 3 60.5 iot_data 8.完成以上任务后请做以下步骤: (1)将 mysql 运行界面截图,另存为 3-6-1.jpg。 (2)将 SQL 语句插入 iot_devices 和 iot_data 表格的结果界面 截图,另存为 3-6-2.jpg,要求截图中能体现 SQL 语句和查询结果。 (3)将查询所有在线的设备名称及其位置的结果截图,要求截图 看的到查找语句和查询结果,另存为 3-6-3.jpg。 (4)将查询设备 TempSensor_001 的所有数据的结果截图,要求 截图看的到查找语句和查询结果,另存为 3-6-4.jpg。 (5)将设备 LightBulb_002 的状态更新为“在线”的结果截图, 要求截图看的到更新语句和更新结果,另存为 3-6-5.jpg。
最新发布
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值