链接:

https://vjudge.net/problem/LightOJ-1297

题意:

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.

思路:

三次函数。

求导,根据图像求二次函数的较小x解即可。

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; int main()
{
int t, cnt = 0;
double l, w;
scanf("%d", &t);
while(t--)
{
printf("Case %d: ", ++cnt);
scanf("%lf%lf", &l, &w);
double res = (4*(l+w)-sqrt(16*(l+w)*(l+w)-4*12*(l*w)))/24.0;
printf("%lf\n", res*(l-2*res)*(w-2*res));
} return 0;
}

LightOJ - 1297 - Largest Box(数学)的更多相关文章

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

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

  2. light oj 1297 Largest Box

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

  3. 1297 - Largest Box(三分)

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

  4. lightoj 1297(三分)

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

  5. LightOJ 1030 Discovering Gold 数学期望计算

    题目大意:给出长度为n的一条隧道,每个位置都有一定数量的财宝.给你一枚骰子,roll到几点就前进几步,如果即将到达的地方超过了这条隧道长度,就重新roll一次,走到n点结束.求这个过程能收获多少财宝. ...

  6. LightOJ - 1214-Large Division(数学,同余)

    链接: https://vjudge.net/problem/LightOJ-1214 题意: Given two integers, a and b, you should check whethe ...

  7. LightOJ - 1148-Mad Counting (数学)

    链接: https://vjudge.net/problem/LightOJ-1148 题意: Mob was hijacked by the mayor of the Town "Trut ...

  8. lightoj--1294--Largest Box(三分)

    Largest Box Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Submit Sta ...

  9. LightOJ 1282 Leading and Trailing (快数幂 + 数学)

    http://lightoj.com/volume_showproblem.php?problem=1282 Leading and Trailing Time Limit:2000MS     Me ...

随机推荐

  1. HDFS面试题

    hadoop节点动态上线下线怎么操作? )节点上线操作: 当要新上线数据节点的时候,需要把数据节点的名字追加在 dfs.hosts 文件中 ()关闭新增节点的防火墙 ()在 NameNode 节点的 ...

  2. 【LEETCODE】42、922. Sort Array By Parity II

    package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...

  3. AX2009取销售订单的税额

    直接用以下方法即可: Tax::calcTaxAmount(salesLine.TaxGroup, salesLine.TaxItemGroup, systemDateGet(),    salesL ...

  4. Java中Date时区的转换

    1.Date中保存的是什么?  在java中,只要我们执行 Date date = new Date(); 就可以得到当前时间.如: Date date = new Date(); System.ou ...

  5. node-red 使用 创建第一个流程

    前言 这只是一个简单的示例,具体详细文档去官网查看 官网指南:https://nodered.org/docs/user-guide/ 打开浏览器,进入编辑器页面:http://localhost:1 ...

  6. Java Web 深入分析(12) JVM(2) 垃圾收集与内存分配

    前言 java的内存分配和垃圾回收往往是影响系统性能和并发能力的主要因素,虚拟机提供许多的参数就是为了根据不同环境和请教下进行调优,没有最好的调优也没有固定的调优.需要我们深入的去了解jvm的各个垃圾 ...

  7. Java操作Hadoop集群

    mavenhdfsMapReduce 1. 配置maven环境 2. 创建maven项目 2.1 pom.xml 依赖 2.2 单元测试 3. hdfs文件操作 3.1 文件上传和下载 3.2 RPC ...

  8. html 滚动条样式

    转载:https://www.cnblogs.com/yclblog/p/6806496.html /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ ::-webkit-scrollbar ...

  9. ORM 查询练习

    目录 ORM 查询练习 表结构 练习题 测试数据 准备 参考答案 ORM 查询练习 表结构 # 书 class Book(models.Model): title = models.CharField ...

  10. iphone NSTimer invalidate 和 release 释放问题

    来源:http://hi.baidu.com/douxinchun/item/920a7655fe7f3fd8d48bacaf 最近在使用NSTimer的时候,遇到了一些内存错误的问题,找了一片很好的 ...