链接:

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. liunx 定时任务执行java程序配置流程

    java jar包使用build fat jar进行打包 ------------------liunx任务创建--------------------------- 1.查看现有任务计划: cron ...

  2. 函数的练习3——python编程从入门到实践

    8-12 三明治: 编写一个函数,它接受顾客要在三明治中添加的一系列食材.这个函数只有一个参数(它收集函数调用中提供的所有食材),并打印一条消息,对顾客点的三明治进行概述.调用这个函数三次,每次提供不 ...

  3. 15 IO流(十二)——数据流Data InputStream/OutputStream 未学会

    数据流的引入 Data流的父类是Filter抽象基类,也就是说Data流是装饰流. 数据流可以将数据的类型也一起传输. 数据流的读取写入顺序(数据类型的读写顺序)需要一致. 未完成代码 /** *Da ...

  4. L2R 三:常用工具包介绍之 XGBoost与LightGBM

    L2R最常用的包就是XGBoost 和LightGBM,xgboost因为其性能及快速处理能力,在机器学习比赛中成为常用的开源工具包, 2016年微软开源了旗下的lightgbm(插句题外话:微软的人 ...

  5. PB数据窗口只存储过程数据源创建

    必须在 Manual Rault Set 上打勾,不然不能设置显示列. 显示列的数据必须和存储过程返回值的顺序一致,否则会出现数据和列名两边不对应的情况

  6. module 'pip._internal' has no attribute 'pep425tags'

    一.问题分析 这是python 3.x不能用2.x的版本问题 二.解决方案 import wheel.pep425tags as w print(w.get_supported()) 输出: [('c ...

  7. k8s部署traefik

    基础知识 同nginx相比,traefik能够自动感知后端容器变化,从而实现自动服务发现.  traefik部署在k8s上分为daemonset和deployment两种方式各有优缺点: daemon ...

  8. 利用ime-mode设置文本框只能输入正整数

    html: <input type="text" id="packageratio"style="ime-mode: disabled;&quo ...

  9. JAVA - Windows下JDK默认安装的配置参数

    JDK版本1.8 JAVA_HOME C:\Program Files\Java\jdk1.8.0_60 CLASSPATH .;%%JAVA_HOME%%\lib;%%JAVA_HOME%%\lib ...

  10. 【JUC】4.Synchronized与ReentrantLock对比

    与synchronized相同,ReentrantLock也是一种互斥锁: synchronized与ReentrantLock的对比: 都是可重入锁 可以再次获取自己的内部锁,即:一个线程获取某对象 ...