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 ...
随机推荐
- Apsara Clouder专项技能认证:实现调用API接口
一.API 简介 1.API 的概念 API(Application Programming Interface应用程序编程接口)是一些预定义的函数,目的是提供应用程序与开发人员基于某软件或硬件得以访 ...
- COMET探索系列三【异步通知服务器关闭数据连接实现思路】
在小编络络 COMET实践笔记一文中注意事项中有这么一段话 使用长连接时, 存在一个很常见的场景:客户端需要关闭页 面,而服务器端还处在读取数据的阻塞状态,客户端需要及时通知服务器端关闭数据连接.服务 ...
- Qt uchar * 转 QImage
QImage(uchar * data, int width, int height, Format format) QImage(const uchar * data, int width, int ...
- OpenAL介绍
OpenAL(Open Audio Library)是自由软件界的跨平台音效API,由Loki Software,使用在Windows.Linux 系统上,用在音效缓冲和收听中编码. OpenAL设计 ...
- @echo off 批处理
一个批处理文件 @echo off ipconfig /all @pause -------------------------------- @echo off 是什么意思 就是说关闭回显@echo ...
- a, b = a, a+b 和a=b b=a+b的区别
n,a,b=0,0,1 while n<5: print(b) a,b=b,a+b n=n+1 和 n,a,b=0,0,1 while n<5: print(b) a=b b=a+b n= ...
- python jQuery筛选器
筛选器:$(this).next() 下一个 $(this).prev 上一个 $(this).parent() 父 $(this).children() 孩 $(th ...
- tar:file-changed-as-we-read-it报错处理
在使用tar命令对Mysql的数据目录进行备份打包时出现如下报错: tar cvzf mysql.tgz mysql /bin/tar: /path/to/mysql: file changed as ...
- 测试用例设计经典面试题之电梯、杯子、笔、桌子、洗衣机、椅子、ATM等
测试用例设计经典面试题之电梯.杯子.笔.桌子.洗衣机.椅子.ATM等 1.测试项目:电梯 需求测试:查看电梯使用说明书.安全说明书等 界面测试:查看电梯外观 功能测试:测试电梯能否实现正常的上升和下降 ...
- 【年度开源、工具合集】牛津计划,DMTK,Graph Engine…提高你的工作效率!
本篇合集包括以下三个部分的内容: 1.微软亚洲研究院过去一年的所有开源合集,如分布式机器学习工具包DMTK等. 2.利用微软研究院的技术提高工作效率的工具合集,如让没有机器学习背景的开发人员也能开发出 ...