light oj 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 |
求导 找点
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define DD double
using namespace std;
DD w,l;
DD f(DD x)
{
return x*(w-2*x)*(l-2*x);
}
int main()
{
int t,k,i;
scanf("%d",&t);
k=1;
while(t--)
{
scanf("%lf%lf",&l,&w);
DD b=(-4)*(w+l);
DD a=12;
DD c=w*l;
DD x1=(sqrt(b*b-4*a*c)-b)/(2*a);
DD x2=(-sqrt(b*b-4*a*c)-b)/(2*a);
printf("Case %d: ",k++);
printf("%.7lf\n",max(f(x1),f(x2)));
}
return 0;
}
light oj 1297 Largest Box的更多相关文章
- 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的正方形,如下图所示,然后折成一个无盖的纸盒, ...
- Light OJ 1114 Easily Readable 字典树
题目来源:Light OJ 1114 Easily Readable 题意:求一个句子有多少种组成方案 仅仅要满足每一个单词的首尾字符一样 中间顺序能够变化 思路:每一个单词除了首尾 中间的字符排序 ...
- Light OJ 1429 Assassin`s Creed (II) BFS+缩点+最小路径覆盖
题目来源:Light OJ 1429 Assassin`s Creed (II) 题意:最少几个人走全然图 能够反复走 有向图 思路:假设是DAG图而且每一个点不能反复走 那么就是裸的最小路径覆盖 如 ...
- Light OJ 1406 Assassin`s Creed 减少国家DP+支撑点甚至通缩+最小路径覆盖
标题来源:problem=1406">Light OJ 1406 Assassin`s Creed 意甲冠军:向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路: ...
- Light OJ 1316 A Wedding Party 最短路+状态压缩DP
题目来源:Light OJ 1316 1316 - A Wedding Party 题意:和HDU 4284 差点儿相同 有一些商店 从起点到终点在走过尽量多商店的情况下求最短路 思路:首先预处理每两 ...
- light oj 1007 Mathematically Hard (欧拉函数)
题目地址:light oj 1007 第一发欧拉函数. 欧拉函数重要性质: 设a为N的质因数.若(N % a == 0 && (N / a) % a == 0) 则有E(N)=E(N ...
- Light OJ 1406 Assassin`s Creed 状态压缩DP+强连通缩点+最小路径覆盖
题目来源:Light OJ 1406 Assassin`s Creed 题意:有向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路:最少的的人能够走全然图 明显是最小路径覆盖问题 ...
随机推荐
- Oracle删除所有表
Oracle 清理用户所有的表 PLSQL中执行语句 select 'drop '||object_type||' '||object_name||';' from user_objects; 结果集 ...
- ASP.NET 学习博客
ASP.NET MVC5 网站开发实践 http://www.cnblogs.com/mzwhj/p/3537145.html 基于MVC4+EasyUI的Web开发框架形成之旅 http://www ...
- 10个最好的 jQuery 视频插件(转)
在这篇文章中已经收集了 10 个最佳的 jQuery 视频插件,帮助开发人员容易地实现网站播放影片功能.可以显示视频和视频播放列表. 1. Bigvideo.js BigVideo.js 是一个 jQ ...
- gei shilei d
body, p { margin: 0; padding: 0; font-size: 16px; } div { margin: 0 auto; } .wrapper { width: 1080px ...
- .net和MVC中的json值和List<T>和DataTable的一些转换
1.List<T>集合转换为Json值 List<ReportModel> dtList = new List<ReportModel>(); JsonResult ...
- Ubuntu 14.04远程登录服务器--ssh的安装和配置
ssh是一种安全协议,主要用于给远程登录会话数据进行加密,保证数据传输的安全,现在介绍一下如何在Ubuntu 14.04上安装和配置ssh 1.更新源列表 打开"终端窗口",输入& ...
- 使用php实现权限管理模块
在说权限管理模块前,应该先知道权限管理模块要有哪些功能: 1.用户只能访问,指定的控制器,指定的方法 2.用户可以存在于多个用户组里 3.用户组可以选择,指定的控制器,指定的方法 4.后台可以添加 ...
- linux是实时系统还是分时操作系统
实时操作系统 实时操作系统 英文称Real Time Operating System,简称RTOS. 1.实时操作系统定义 实时操作系统(RTOS)是指当外界事件或数据产生时,能够接受并以足够快的速 ...
- JAVA大数类练手
今天突然看到了OJ上的大数类题目,由于学习了一点大数类的知识.果断水了6道题......都是非常基础的.就当的练手的吧. 学到的只是一些大数类的基本操作.以后多做点这样的题,争取熟练运用水大数题... ...
- ANDROID_MARS学习笔记_S01原始版_018_SERVICE之Parcel
一.代码 1.xml(1)activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk ...