lightoj--1294--Largest Box(三分)
Time Limit: 2000MS | Memory Limit: 32768KB | 64bit IO Format: %lld & %llu |
Description
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
3
2 10
3.590 2.719
8.1991 7.189
Sample Output
Case 1: 4.513804324
Case 2: 2.2268848896
Case 3: 33.412886
Source
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
double w,l;
double v(double x)
{
return (l-2*x)*(w-2*x)*x;
}
double san(double l,double r)
{
double mid,mm;
while(r-l>1e-10)
{
mid=(l+r)/2;
mm=(mid+r)/2;
if(v(mid)>=v(mm)) //谁大在谁的附近找
r=mm;
else
l=mid;
}
return mid;
}
int main()
{
int t;
int Case=1;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&w,&l);
double num=san(0,min(w,l)/2);
printf("Case %d: %lf\n",Case++,v(num));
}
return 0;
}
lightoj--1294--Largest Box(三分)的更多相关文章
- 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的正方形,如下图所示,然后折成一个无盖的纸盒, ...
- 1297 - Largest Box(三分)
1297 - Largest Box PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB In t ...
- light oj 1297 Largest Box
1297 - Largest Box PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB In t ...
- LightOJ - 1294 - Positive Negative Sign(规律)
链接: https://vjudge.net/problem/LightOJ-1294 题意: Given two integers: n and m and n is divisible by 2m ...
- lightoj 1297(三分)
传送门:Largest Box 题意:长度为L宽度为W的纸四个角去掉x*x的正方形,然后形成一个长方体,问能组成长方体的最大体积为多少. 分析:三分x求最值. #include <cstdio& ...
- 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 ...
随机推荐
- 如何在C#中运行数学表达式字符串
方法1:利用DataTable中的Compute方法 1 string expression = "1+2*3"; 2 DataTable eval = new DataTable ...
- NPOI导出功能
利用NPOI组件将数据中想要的数据导出到excel表格中. demo如下 using System; using System.Collections.Generic; using System.Li ...
- Oracle数据库安装与连接与简介
Oracle数据库的安装 1.登录Oracle官网——试用和下载 2.同意协议--->file1 3.完成配置 4.测试连接:打开Oracle developer--->新建连接,注意用户 ...
- 【Oracle】ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
今天数据库在查询数据的时候显示了这个错误: ORA-01157: cannot identify/lock data file 201 - see DBWR trace file ORA-01110: ...
- 用户 'NT Service\MSSQLServerOLAPService' 登录失败
初学SSAS,部署微软官方示例项目AdventureWorksDW2012Multidimensional时出现错误:用户 'NT Service\MSSQLServerOLAPService' 登录 ...
- smarty 3 + codeigniter 2 + hmvc
参考资料 https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/src/fecd39ccdf56?at=defau ...
- WIN系统查询版本
cmd -> DISM /online /Get-CurrentEdition //查询系统版本 WIN+R -> slmgr.vbs -ipk 查询系统注册信息slmgr.vbs -dl ...
- ZBrush中的PolyPainting如何理解?
什么是PolyPainting? PolyPainting在ZBrush ®中是一种创建纹理的方法,该方法通过对每个多边形顶点应用单一RGB值来着色模型.此方法无需使用UV坐标.通过直接对顶点应用颜色 ...
- vue项目布局
1.底部有分类布局 类似这种底部有分类的,点击四个tap分别道不同的页面这样的,每个页面都是一个路由,把底部作为一个组件在每一个页面中引入就行.组件就是公用的,能公用的就写成组件.如下 { path: ...
- bzoj 1191: [HNOI2006]超级英雄Hero 网络流_残量网络
题目描述: 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的 多少获得不同数目的奖品或奖金.主持人问题准备了若干道题目,只有当选手正确回答一道题后 ...