Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu

Submit
Status

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

Problem Setter: Shahriar Manzoor
Special Thanks: Jane Alam Jan (Description, Solution, Dataset)

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<algorithm>
  4. using namespace std;
  5. double w,l;
  6. double v(double x)
  7. {
  8. return (l-2*x)*(w-2*x)*x;
  9. }
  10. double san(double l,double r)
  11. {
  12. double mid,mm;
  13. while(r-l>1e-10)
  14. {
  15. mid=(l+r)/2;
  16. mm=(mid+r)/2;
  17. if(v(mid)>=v(mm)) //谁大在谁的附近找
  18. r=mm;
  19. else
  20. l=mid;
  21. }
  22. return mid;
  23. }
  24. int main()
  25. {
  26. int t;
  27. int Case=1;
  28. scanf("%d",&t);
  29. while(t--)
  30. {
  31. scanf("%lf%lf",&w,&l);
  32. double num=san(0,min(w,l)/2);
  33. printf("Case %d: %lf\n",Case++,v(num));
  34. }
  35. return 0;
  36. }

lightoj--1294--Largest Box(三分)的更多相关文章

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

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

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

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

  3. 1297 - Largest Box(三分)

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

  4. light oj 1297 Largest Box

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

  5. LightOJ - 1294 - Positive Negative Sign(规律)

    链接: https://vjudge.net/problem/LightOJ-1294 题意: Given two integers: n and m and n is divisible by 2m ...

  6. lightoj 1297(三分)

    传送门:Largest Box 题意:长度为L宽度为W的纸四个角去掉x*x的正方形,然后形成一个长方体,问能组成长方体的最大体积为多少. 分析:三分x求最值. #include <cstdio& ...

  7. uva 1463 - Largest Empty Circle on a Segment(二分+三分+几何)

    题目链接:uva 1463 - Largest Empty Circle on a Segment 二分半径,对于每一个半径,用三分求出线段到线段的最短距离,依据最短距离能够确定当前R下每条线段在[0 ...

  8. UVA10215The Largest/Smallest Box(小数精度)

    本身很容易却因为评测机有毒的一道题,,,看网上题解说最后一个答案要加一个很小的数才能AC,据说是因为没有speci judge #include <iostream> #include & ...

  9. HDU 4717The Moving Points warmup2 1002题(三分)

    The Moving Points Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

随机推荐

  1. Windows 文件自动同步共享工具

    操作地址: http://blog.sina.com.cn/s/blog_1320088ed0102uxln.html下载地址: http://www.zisync.com/download

  2. Javascript Proxy对象 简介

    Javascript Proxy对象 简介 Javascript Proxy对象 改变你操作对象的方式 Proxies 是Javasript对象的中间件 ...或者说至少是那种很早的版本. ES6 中 ...

  3. Android 用Handler和Message实现计时效果及其中一些疑问

    本来是打算继续做天气预报的优化的,但因为某些原因,我要先把之前做的小应用优化一下.所以今天就插播一下用Handler和Message实现计时效果. 首先,简要说明一下,这个应用有两个显示数字的Text ...

  4. Python 之 基础知识(五)

    一.变量 1.引用 id() 函数传参 与 返回值 都是传递保存的数据的引用 2.可变和不可变类型(变量的引用地址只在赋值语句后变化) 不可变类型 内存中的数据不允许被修改 数字类型 int,bool ...

  5. [ Linux ] [ OS ] [ memory ] Linux 如何查看系統硬體的記憶體(RAM)資訊

    cat /proc/meminfo https://blog.longwin.com.tw/2013/05/linux-ram-memory-info-2013/

  6. 「JavaSE 重新出发」05.03.03 使用反射编写泛型数组代码

    Employee[] a = new Employee[100]; // ... // array is full a = Arrays.copyOf(a, 2 * a.length); 如何编写这样 ...

  7. ios 编译版本 最低版本 运行版本 动态链接库

    if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) 运行环境判断: #if __IPHONE_OS_VERSION_ ...

  8. 与PhotoZoom Classic 6相比,Classic 7新增了哪些?

    PhotoZoom Classic 6凭借屡获殊荣的S-Spline XL的专利技术,以清晰和锐利的方式调整照片大小非常简单快捷甚至可以放大和改善互联网上的照片. PhotoZoom Classic ...

  9. Django 了解

    Django是一个开放源代码的Web应用框架 Django也是一个基于 MVC 构造的框架. 但是在Django中,控制器接受用户输入的部分由框架自行处理,所以 Django 里更关注的是模型(Mod ...

  10. let var const

    eslint要求变量声明使用const的,而不是let和var如果可能的话. 如果一个变量只有在声明时才被赋值一次,那么应该使用'const' 'use strict';(function() { v ...