Cake URAL - 1755
1755. Cake
Memory limit: 64 MB
Input
Output
Sample
| input | output |
|---|---|
1 2 3 2 |
300.00000000 0.00000000 |
Problem Source: XI USU Open Personal Contest (March 13, 2010)
可以保证Little Boy能有机会取的自己认为美味度最大的蛋糕。然后要使Karlsson分得的美味度最大,如果Karlsson更喜欢巧克力那就巧克力多分点,反之亦然。从\[\left ( \frac{T}{2a_{2}},0\right),\left ( 0,\frac{T}{2b_{2}}\right),\left ( \frac{T-b_{2}m}{a_{2}},m\right),\left ( n,\frac{T-a_{2}n}{b_{2}}\right)\]取最优解即可
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
double ans = ;
double a1,b1,a2,b2;
double n,m,T;
cin>>a1>>b1>>a2>>b2;
cin>>n>>m;
T = (n*a2+m*b2)/2.0;
double x1;
double x2;
double y1;
double y2;
x1 = T/a2;
y1 = T/b2;
x2 = (T-b2*m)/a2;
y2 = (T-a2*n)/b2;
double x = ,y = ;
if(x1 >= && x1 <= n){
if(x1*a1>=ans){
ans = x1*a1;
x = x1,y=;
}
}else if(y1 >= && y1 <=m){
if(y1*b1>=ans){
ans = y1*b1;
x = , y = y1;
}
}else if(x2 >= && x2 <= n){
if(x2*a1 + m*b1 >=ans){
ans = x2*a1 + m*b1;
x = x2,y=m;
}
}else if(y2 >= && y2 <= m){
if(n*a1 + y2*m >= ans){
ans = n*a1+y2*m;
x = n,y=y2;
}
}
printf("%.8f %.8f\n",x,y);
return ;
}
Cake URAL - 1755的更多相关文章
- Windows 7上执行Cake 报错原因是Powershell 版本问题
在Windows 7 SP1 电脑上执行Cake的的例子 http://cakebuild.net/docs/tutorials/getting-started ,运行./Build.ps1 报下面的 ...
- 2015暑假多校联合---Cake(深搜)
题目链接:HDU 5355 http://acm.split.hdu.edu.cn/showproblem.php?pid=5355 Problem Description There are m s ...
- Scalaz(15)- Monad:依赖注入-Reader besides Cake
我们可以用Monad Reader来实现依赖注入(dependency injection DI or IOC)功能.Scala界中比较常用的不附加任何Framework的依赖注入方式可以说是Cake ...
- uva10167 Birthday Cake
Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them. Now we put t ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
随机推荐
- sequelize 应用hook 实现对分表的访问
https://github.com/cclient/sequelize-shardinghttps://www.npmjs.com/package/sequelize-sharding 实际有效的代 ...
- 系统学习Javaweb10----BootStrap2
学习内容: 1.BootStrap-轮播图 2.BootStrap-排版对齐方式 3.BootStrap-表单元素 4.BootStrap-分页条
- linux文件系统与链接
Linux的文件属性图1 图1 linux的文件属性 ls -lhi -l 长格式 -h 人性化 -i inodo -d 看目录自己的信息 inode 源自于文件系统 分区 平面设计图 格式化 施 ...
- jQuery性能优化与技巧
1.使用最新版本的jQuery类库 jQuery的每一个新的版本都会较上一版进行Bug修复和一些优化,同时也会包含一些创新,所以建议使用最新版本的jQuery来提高性能,需要注意的是在更换版本之后,要 ...
- VisualStudioAddIn2017.vsix的下载安装和使用
本加载项是用于Visual Studio的,下载以后按照如下步骤进行安装: 完全退出Visual Studio 把下载了的文件解压缩,会产生一个VisualStudioAddIn2017.vsix文件 ...
- QLIKVIEW基础设置及初步了解
改变语言环境 开发工具条勾选出来 创建selection box 创建search box 编辑脚本 重加载数据 基本联动思路:table view tableview load FSUPPLIERI ...
- ionic2踩坑之订阅发布模式的实现
原文地址:http://www.cnblogs.com/eccainiao/p/6429536.html 转载请说明. 在ionic2中实现订阅发布模式,需要用到Events. Events下面有三个 ...
- 3DSMAX卸载/完美解决安装失败/如何彻底卸载清除干净3DSMAX各种残留注册表和文件的方法
在卸载3dsmax重装3dsmax时发现安装失败,提示是已安装3dsmax或安装失败.这是因为上一次卸载3dsmax没有清理干净,系统会误认为已经安装3dsmax了.有的同学是新装的系统也会出现3ds ...
- 实现一个简易的HashMap
实现一个键的类型为int,值的类型为int的HashMap 输入一个T,表示操作次数: 之后每行接一个操作,可以包括插入.删除.修改.查询.清空.判断是否有这个键: 因为是刚学完随手敲的,所以功能粗糙 ...
- Oauth2.0 协议简介及 php实例代码
转自:http://www.dahouduan.com/2017/11/21/oauth2-php/ https://blog.csdn.net/halsonhe/article/details/81 ...