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 ...
随机推荐
- string模板
string模块中包含了一个很有用的Template类,可以先写好字符串模板,后期使用的时候直接替换就可以了. 模板中使用$作为占位符前缀,使用{}包裹占位符以支持间断的标量名,使用$ ...
- select标签操作大全
http://blog.csdn.net/hhhh2012/article/details/8610336
- selenium + python自动化测试环境搭建--亲测
环境准备: 1.下载所学安装包: setuptools https://pypi.python.org/packages/2.7/s/setuptools/ selenium https://pypi ...
- strlen源码剖析
学习高效编程的有效途径之一就是阅读高手写的源代码,CRT(C/C++ Runtime Library)作为底层的函数库,实现必然高效.恰好手中就有glibc和VC的CRT源代码,于是挑了一个相对简 ...
- Windows10 上运行Ubuntu Bash
Windows10 上运行Ubuntu Bash 2016年4月6日,Windows 10 Insider Preview 发布的版本 14316,添加了Ubuntu Bash,在Windows上提供 ...
- perl5 第九章 关联数组/哈希表
第九章 关联数组/哈希表 by flamephoenix 一.数组变量的限制二.定义三.访问关联数组的元素四.增加元素五.创建关联数组六.从数组变量复制到关联数组七.元素的增删八.列出数组的索引和值九 ...
- Strata 2014 上的 AzureCAT 粉笔会谈
本周,AzureCAT 团队非常高兴在 Strata 会议上首次集体亮相.对于那些对 AzureCAT 团队不太熟悉的人来说,我们是 Microsoft 云与企业部门一个核心的国际性团队,由大约 ...
- Zookeeper 在Hadoop中的应用
Zookeeper 简单介绍 Zookeeper 分布式服务框架是 Apache Hadoop 的一个子项目.它主要是用来解决分布式应用中常常遇到的一些数据管理问题,如:统一命名服务.状态同步服务.集 ...
- YUV / RGB 格式及快速转换算法
1 前言 自然界的颜色千变万化,为了给颜色一个量化的衡量标准,就需要建立色彩空间模型来描述各种各样的颜色,由于人对色彩的感知是一个复杂的生理和心理联合作用 的过程,所以在不同的应用领域中为了更好更准确 ...
- CSS3学习笔记之linear-gradient
我觉得CSS3很不错,自己也稍微看过,并且尝试过一些属性.对我自己而言,我没有勇气说我学过CSS3,我觉得任何自己看来很小的事情,也只是站在自己的角度来评判.就算的是"简单的"HT ...