hdu 3349 lazy gege

lazy gege

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 902    Accepted Submission(s): 348

Problem Description

Gege hasn‘t tidied his desk for long,now his desk is full of things.

This morning Gege bought a notebook,while to find somewhise to put it troubles him.

He wants to tidy a small area of the desk, leaving an empty area, and put the notebook there, the notebook shouldn‘t fall off the desk when putting there.

The desk is a square and the notebook is a rectangle, area of the desk may be smaller than the notebook.

here‘re two possible conditions:

Can you tell Gege the smallest area he must tidy to put his notebook?

Input

T(T<=100) in the first line is the case number.

The next T lines each has 3 real numbers, L,A,B(0< L,A,B <= 1000).

L is the side length of the square desk.

A,B is length and width of the rectangle notebook.

Output

For each case, output a real number with 4 decimal(printf("%.4lf",ans) is OK), indicating the smallest area Gege should tidy.

Sample Input

3
10.1 20 10
3.0 20 10
30.5 20.4 19.6

Sample Output

25.0000
9.0000
96.0400

题意:

给你一张边长为L的正方形桌子,一本A*B的笔记本,求笔记本放桌子上的最小面积。

题解:只需要吧笔记本的重心放在桌子上就行了

CODE:

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

double a,b,c;

int main() {
    int t;
    cin>>t;
    while(t--) {
        scanf("%lf%lf%lf",&a,&b,&c);
        if(b<c)
            swap(b,c);
        double x=b/2;
        double y=c/2;
        double r=sqrt(2*a*a);
        double ans;
        if(r<y) {
            ans=a*a;
        } else {
            if(y<r/2) {
                ans=y*y;
            } else {
                double z=r-y;
                ans=a*a-z*z;
            }
        }
        printf("%.4f\n",ans);
    }
    return 0;
}
时间: 2024-11-08 22:34:03

hdu 3349 lazy gege的相关文章

hdu 6071 Lazy Running(同余最短路)

题目链接:hdu 6071 Lazy Running 题意: 给你4个点,每两个相邻点有一个距离,现在让你在这四个点来回跑步,从2开始,最后回到2,问你找一个距离ans,ans>=k,问最小的ans是多少. 题解: Claris的官方题解: 1 #include<bits/stdc++.h> 2 #define F(i,a,b) for(int i=(a);i<=(b);++i) 3 using namespace std; 4 using ll=long long; 5 6 co

HDU 6071 Lazy Running (同余最短路)

Lazy Running Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 101    Accepted Submission(s): 40 Problem Description In HDU, you have to run along the campus for 24 times, or you will fail in PE

HDU 6071 Lazy Running (同余最短路 dij)

Lazy Running Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1384    Accepted Submission(s): 597 Problem Description In HDU, you have to run along the campus for 24 times, or you will fail in

HDU 6071 Lazy Running(最短路)

[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6071 [题目大意] 给出四个点1,2,3,4,1和2,2和3,3和4,4和1 之间有路相连, 现在从2点出发,最后回到2点,要求路径大于等于K,问路径长度最短是多少 [题解] 取一条与2相连的权值最小的边w. 若存在一条从起点到终点的长度为k的路径, 那么必然存在一条长度为k+2w的路径,只要一开始在那条边上往返走就好了. 设dij表示从起点到i,路径长度模2w为j时,路径长度的最小值. 用最短

HDU2010省赛集训队选拔赛(校内赛) G

lazy gege Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 948    Accepted Submission(s): 361 Problem Description Gege hasn't tidied his desk for long,now his desk is full of things. This mornin

noip考前抱佛脚 数论小总结

exCRT 求解韩信点兵问题,常见的就是合并不同\(mod\). 先mo一发高神的板子 for(R i=2;i<=n;++i){ ll Y1,Yi,lcm=Lcm(p[i],p[1]); exgcd(p[1],p[i],a[i]-a[1],Y1,Yi); add(a[1],mul(p[1],Y1,lcm),lcm),p[1]=lcm; } 思想是合并方程组,现在假设我们要求解的是: \[x-p_0*y_0=a_0\]\[x-p_i*y_i=a_i\] \(x\)是实际的值,显然有: \[p_0*

HDU 1698 Just a Hook (线段树 成段更新 lazy-tag思想)

题目链接 题意: n个挂钩,q次询问,每个挂钩可能的值为1 2 3,  初始值为1,每次询问 把从x到Y区间内的值改变为z.求最后的总的值. 分析:用val记录这一个区间的值,val == -1表示这个区间值不统一,而且已经向下更新了, val != -1表示这个区间值统一, 更新某个区间的时候只需要把这个区间分为几个区间更新就行了, 也就是只更新到需要更新的区间,不用向下更新每一个一直到底了,在更新的过程中如果遇到之前没有向下更新的, 就需要向下更新了,因为这个区间的值已经不统一了. 其实这就

判断相同区间(lazy) 多校8 HDU 5828 Rikka with Sequence

1 // 判断相同区间(lazy) 多校8 HDU 5828 Rikka with Sequence 2 // 题意:三种操作,1增加值,2开根,3求和 3 // 思路:这题与HDU 4027 和HDU 5634 差不多 4 // 注意开根号的话,遇到极差等于1的,开根号以后有可能还是差1.如 5 // 2 3 2 3... 6 // 8 9 8 9... 7 // 2 3 2 3... 8 // 8 9 8 9... 9 // 剩下就是遇到区间相等的话,就直接开根号不往下传 10 11 12

HDU 3397 双lazy标记的问题

题目大意 对一个只有0和1的序列,支持以下几种操作1.将区间所有的值变成12.将区间所有的值变为03.将区间的0和1翻转(0变成1 1变成0)4.求区间中1的个数5.求区间连续最长的1的个数 http://vjudge.net/problem/viewProblem.action?id=14689 整整一下午...简直把自己修改的都要哭了 lazy标记有先后关系,如to[]覆盖后,那么rev[]翻转标记就应该重新赋为0 我们在pushdown中,是对孩子节点进行更新,那么更新的也是孩子节点的la