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

求导 找点

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<math.h>
  4. #include<algorithm>
  5. #define DD double
  6. using namespace std;
  7. DD w,l;
  8. DD f(DD x)
  9. {
  10. return x*(w-2*x)*(l-2*x);
  11. }
  12. int main()
  13. {
  14. int t,k,i;
  15. scanf("%d",&t);
  16. k=1;
  17. while(t--)
  18. {
  19. scanf("%lf%lf",&l,&w);
  20. DD b=(-4)*(w+l);
  21. DD a=12;
  22. DD c=w*l;
  23. DD x1=(sqrt(b*b-4*a*c)-b)/(2*a);
  24. DD x2=(-sqrt(b*b-4*a*c)-b)/(2*a);
  25. printf("Case %d: ",k++);
  26. printf("%.7lf\n",max(f(x1),f(x2)));
  27. }
  28. return 0;
  29. }

  

light oj 1297 Largest Box的更多相关文章

  1. 1297 - Largest Box(三分)

    1297 - Largest Box   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB In t ...

  2. LightOJ - 1297 - Largest Box(数学)

    链接: https://vjudge.net/problem/LightOJ-1297 题意: In the following figure you can see a rectangular ca ...

  3. LightOJ - 1297 Largest Box LightOJ(一元三次方程求极大值)

    题目链接:https://vjudge.net/contest/28079#problem/K 题目大意:给你一个长为L,宽为W的纸片,四个角剪掉边长为x的正方形,如下图所示,然后折成一个无盖的纸盒, ...

  4. Light OJ 1114 Easily Readable 字典树

    题目来源:Light OJ 1114 Easily Readable 题意:求一个句子有多少种组成方案 仅仅要满足每一个单词的首尾字符一样 中间顺序能够变化 思路:每一个单词除了首尾 中间的字符排序 ...

  5. Light OJ 1429 Assassin`s Creed (II) BFS+缩点+最小路径覆盖

    题目来源:Light OJ 1429 Assassin`s Creed (II) 题意:最少几个人走全然图 能够反复走 有向图 思路:假设是DAG图而且每一个点不能反复走 那么就是裸的最小路径覆盖 如 ...

  6. Light OJ 1406 Assassin`s Creed 减少国家DP+支撑点甚至通缩+最小路径覆盖

    标题来源:problem=1406">Light OJ 1406 Assassin`s Creed 意甲冠军:向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路: ...

  7. Light OJ 1316 A Wedding Party 最短路+状态压缩DP

    题目来源:Light OJ 1316 1316 - A Wedding Party 题意:和HDU 4284 差点儿相同 有一些商店 从起点到终点在走过尽量多商店的情况下求最短路 思路:首先预处理每两 ...

  8. light oj 1007 Mathematically Hard (欧拉函数)

    题目地址:light oj 1007 第一发欧拉函数. 欧拉函数重要性质: 设a为N的质因数.若(N % a == 0 && (N / a) % a == 0) 则有E(N)=E(N ...

  9. Light OJ 1406 Assassin`s Creed 状态压缩DP+强连通缩点+最小路径覆盖

    题目来源:Light OJ 1406 Assassin`s Creed 题意:有向图 派出最少的人经过全部的城市 而且每一个人不能走别人走过的地方 思路:最少的的人能够走全然图 明显是最小路径覆盖问题 ...

随机推荐

  1. listview滚动时背景闪烁,背景黑或白问题解决

    android在使用listview时出现滚动时背景闪烁,变成背景黑或白的问题这样处理: 1:在布局文件中listview标签中加入: android:cacheColorHint="#00 ...

  2. CODEVS 2102 石子归并 2

    [题目描述 Descriptin] 在一个园形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一堆的石子数,记为该次合并的得分.试设计出1个算法, ...

  3. I2C总线模拟(郭天祥视屏)

    电路图 思路 1.向EEPROM中通过I2C总线写入一个字节 2.通过I2C总线读出写入的字节 3.如果写入和读出成功点亮发光二极管 程序 #include <REGX51.H> #def ...

  4. 微软Hololens学院教程-Hologram 210 Gaze(凝视)【微软教程已经更新,本文是老版本】

    这是老版本的教程,为了不耽误大家的时间,请直接看原文,本文仅供参考哦!原文链接:https://developer.microsoft.com/EN-US/WINDOWS/HOLOGRAPHIC/ho ...

  5. 关于c++字符串的while(*temp++)

    首先,上一段代码 static bool reverse_str(const char *str) { const char *temp=str; while(*temp++); temp-=; // ...

  6. HTML5-canvas实例:刮刮乐游戏

    实现方法: (1)利用canvas画布,fillRect()描绘出一个矩形(不是透明),定位盖在某个标签如div上面(这个标签写着中奖的信息) (2)globalCompositeOperation ...

  7. BT5之配置笔记

    BT5本来就是用Ubuntu 10.04做得蓝本,所以,我在配置BT5的时候,基本上都是按照Ubuntu 10.04的配置方法,在配置BT5 1    系统基本设置 1.1  安装Ubuntu10.0 ...

  8. 黑客是怎样绕过WAF之三重防护绕过讲解

    什么是WAF Web Application Firewall 通过执行一系列针对HTTP/HTTPS的安全策略来防御对Web应用的攻击. 目前主要有单设备WAF与云WAF WAF的现状 1.太多数W ...

  9. apache的 .htaccess文件的常用配置

    使用.htaccess文件需要注意的地方: 1.找到配置文件httpd.conf,将override的值改成all.如下图:(如果不设置成all,apache将忽略.htaccess文件)

  10. Sequence Assignments FRM-41830: List of Value contains no entries.

    SYMPTOMS ============================================================ GL > Setup > Financials ...