LightOJ - 1297 - Largest Box(数学)
链接:
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(数学)的更多相关文章
- LightOJ - 1297 Largest Box LightOJ(一元三次方程求极大值)
题目链接:https://vjudge.net/contest/28079#problem/K 题目大意:给你一个长为L,宽为W的纸片,四个角剪掉边长为x的正方形,如下图所示,然后折成一个无盖的纸盒, ...
- light oj 1297 Largest Box
1297 - Largest Box PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB In t ...
- 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 题意:长度为L宽度为W的纸四个角去掉x*x的正方形,然后形成一个长方体,问能组成长方体的最大体积为多少. 分析:三分x求最值. #include <cstdio& ...
- LightOJ 1030 Discovering Gold 数学期望计算
题目大意:给出长度为n的一条隧道,每个位置都有一定数量的财宝.给你一枚骰子,roll到几点就前进几步,如果即将到达的地方超过了这条隧道长度,就重新roll一次,走到n点结束.求这个过程能收获多少财宝. ...
- LightOJ - 1214-Large Division(数学,同余)
链接: https://vjudge.net/problem/LightOJ-1214 题意: Given two integers, a and b, you should check whethe ...
- LightOJ - 1148-Mad Counting (数学)
链接: https://vjudge.net/problem/LightOJ-1148 题意: Mob was hijacked by the mayor of the Town "Trut ...
- lightoj--1294--Largest Box(三分)
Largest Box Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Sta ...
- LightOJ 1282 Leading and Trailing (快数幂 + 数学)
http://lightoj.com/volume_showproblem.php?problem=1282 Leading and Trailing Time Limit:2000MS Me ...
随机推荐
- Spring MVC拦截器完整代码示例
拦截器的作用: 编写一个自定义的类,实现相关拦截器接口: preHandler不放行,直接return false:直接跳转到错误页面error.jsp postHandler后置处理器,也就是C ...
- Luogu4827 Crash的文明世界 组合、树形DP
传送门 又是喜闻乐见的\(k\)次幂求和题目 那么\(S(x) = \sum\limits_{i=1}^n dist(i,x)^k = \sum\limits_{i=1}^n \sum\limits_ ...
- TeX 家族(TeX, pdfTeX, XeTeX, LuaTeX, LaTeX, pdfLaTeX, XeLaTeX …)
TeX 家族 带有 TeX 的词,仅仅是本文就已经提到了 TeX, LaTeX, XeLaTeX.通常中国学生面对不了解意思的一群形近单词,都会有一种「本能的恐惧」(笑~).因此,「大神们」在为新手介 ...
- Oracle---使用日常
一.union和union all union和union all的区别是,union会自动压缩多个结果集合中的重复结果,而union all则将所有的结果全部显示出来,不管是不是重复. Union因 ...
- ADO.NET 三(Command)
操作数据库需则要用到 Command 类中提供的属性和方法.下面来介绍一下如何使用 Command 类来操作数据表中的数据. Command 类概述 在 System.Data.SqlClient 命 ...
- React 中的 定义组件的 两种方式
React 中创建 Components 的方式有两种:Function and Class 定义一个组件最简单的方法就是写一个 JavaScript 函数 function Welcome(prop ...
- c++ 使用torchscript 加载训练好的pytorch模型
1.首先官网上下载libtorch,放到当前项目下 2.将pytorch训练好的模型使用torch.jit.trace导出为.pt格式 import torch from skimage import ...
- HP-UX 解压缩tar.gz
对于tar.gz包分两步: gunzip *.tar.gz 解压为tar包 tar xf *.tar 解压完成
- uboot使用脚本
使用mkimage命令 # mkimage -A ARM -O linux -T script -C none -n "script" -d *.sh *.img # tftp x ...
- Sqlite常用命令及基本知识
sqlite菜鸟教程:http://www.runoob.com/sqlite/sqlite-tutorial.html 常用命令: .sqlite3 --从dos命令模式进入sqlite命令 ...