1297 - Largest Box(三分)
| Time Limit: 2 second(s) | Memory Limit: 32 MB |
In the following figure you can see a rectangular card. The width of the card is W and length of the card is L and thickness is zero. Four (x*x) squares are cut from the four corners of the card shown by the black dotted lines. Then the card is folded along the magenta lines to make a box without a cover.
Given the width and height of the box, you will have to find the maximum volume of the box you can make for any value of x.
Input
Input starts with an integer T (≤ 10000), denoting the number of test cases.
Each case starts with a line containing two real numbers L and W (0 < L, W < 100).
Output
For each case, print the case number and the maximum volume of the box that can be made. Errors less than 10-6 will be ignored.
Sample Input |
Output for Sample Input |
|
3 2 10 3.590 2.719 8.1991 7.189 |
Case 1: 4.513804324 Case 2: 2.2268848896 Case 3: 33.412886 |
题解:方程式列一下,因为是3次方,一看就是求极值的,但是注意范围是0,min(w,h)/2,三分写一下就过了。。。
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define mem(x,y) memset(x,y,sizeof(x))
#define ZR (4*W+4*L)*(4*W+4*L)-48*W*L
using namespace std;
const int INF=0x3f3f3f3f;
double L,W;
double js(double x){
return x*(L-*x)*(W-*x);
}
double sf(double l,double r){
double mid,mm;
while(r-l>1e-){
mid=(l+r)/;
mm=(mid+r)/;
if(js(mid)>=js(mm))r=mm;
else l=mid;
}
return mid;
}
int main(){
int T,flot=;
scanf("%d",&T);
while(T--){
scanf("%lf%lf",&L,&W);
double x=sf(,min(L,W)/);
// printf("%f\n",x);
printf("Case %d: %lf\n",++flot,js(x));
}
return ;
}
1297 - Largest Box(三分)的更多相关文章
- light oj 1297 Largest Box
1297 - Largest Box PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB In t ...
- LightOJ - 1297 - Largest Box(数学)
链接: https://vjudge.net/problem/LightOJ-1297 题意: In the following figure you can see a rectangular ca ...
- LightOJ - 1297 Largest Box LightOJ(一元三次方程求极大值)
题目链接:https://vjudge.net/contest/28079#problem/K 题目大意:给你一个长为L,宽为W的纸片,四个角剪掉边长为x的正方形,如下图所示,然后折成一个无盖的纸盒, ...
- lightoj 1297(三分)
传送门:Largest Box 题意:长度为L宽度为W的纸四个角去掉x*x的正方形,然后形成一个长方体,问能组成长方体的最大体积为多少. 分析:三分x求最值. #include <cstdio& ...
- lightoj--1294--Largest Box(三分)
Largest Box Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Sta ...
- uva 1463 - Largest Empty Circle on a Segment(二分+三分+几何)
题目链接:uva 1463 - Largest Empty Circle on a Segment 二分半径,对于每一个半径,用三分求出线段到线段的最短距离,依据最短距离能够确定当前R下每条线段在[0 ...
- UVA10215The Largest/Smallest Box(小数精度)
本身很容易却因为评测机有毒的一道题,,,看网上题解说最后一个答案要加一个很小的数才能AC,据说是因为没有speci judge #include <iostream> #include & ...
- HDU 4717The Moving Points warmup2 1002题(三分)
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- HDU 4717 The Moving Points (三分)
The Moving Points Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
随机推荐
- The Painter's Partition Problem Part II
(http://leetcode.com/2011/04/the-painters-partition-problem-part-ii.html) This is Part II of the art ...
- MySql 日期字符串类型互转
1.data_format 日期转字符串 select date_format(Now(), '%Y-%m-%d %H:%i'); 2.str_to_date 字符串转日期 select str_to ...
- MYSQL异常和错误机制
BEGIN ; ; ; START TRANSACTION; call put_playerbehavior(i_playerid,i_gameid,i_channelid,i_acttime,@a) ...
- React使用笔记1-React的JSX和Style
React使用笔记1-React的JSX和Style Date: 2015-11-27 20:56 Category: Web Tags: JavaScript Author: 刘理想 [toc] 1 ...
- FPGA工程中用C语言对文件进行处理_生成mif文件
本博客中有用verilog处理文件数据的代码,本博文采用C 处理文件中的数据. 有时候要生成一个mif文件—— altera memory initial file.本次工程中我得到的是一个大型的数 ...
- TexturePacker
TexturePacker 可以免费申请,希望可以申请到.
- Oracle SQL篇(四)group by 分组与分组的加强 rollup
分组操作group by 和分组的强化(rollup) 分组操作和分组函数的使用,对于编写SQL语句的人来说,是最基本的概念. 我们来看下面的例子: 在这里我们使用员工表EMP scott@D ...
- MCE遥控---用遥控器玩电脑
实现功能:利用Vista/Windows7的Media Center或者iMCE的支持,配上电脑遥控器,就可以在电视上用遥控器玩电脑,看高清.听音乐.看照片.录电视等.遥控器比鼠标操作起来更加自然,家 ...
- HDU 1147 Pick-up sticks
题解:每放一根棍子,都判断一下它与它前面的且在顶端的棍子是否相交,相交的话则将相应的棍子从解空间中除去. #include <cstdio> const double eps=1e-14; ...
- poj 3356 AGTC(线性dp)
题目链接:http://poj.org/problem?id=3356 思路分析:题目为经典的编辑距离问题,其实质为动态规划问题: 编辑距离问题定义:给定一个字符串source,可以对其进行复制,替换 ...