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 ...
随机推荐
- Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionExcep linux下mysql修改连接超时wait_timeout修改后就ok了
Linux下mysql修改连接超时wait_timeout 1,首先: show variables like '%timeout%': 显示结果: +------------------------ ...
- Jarque-Bera test|pp图|K-S检验|
Jarque-Bera test: 如何绘制pp图? 找该直线的截距和斜率,通过截距和斜率的值找到正态参数均值和方差,可对这些正态参数进行正态检验. K-S检验的的特点? 并不是只针对正态分布,是 ...
- Ubuntu navicat 连接mysql:access denied for user 'root'@'localhost'
真是醉了,Ubuntu装了navicat后,准备在桌面建立图标不成,结果直接打开后连接mysql都不行,真坑,奈何远程连接就成,这就尬了,今天终于解决了 问题 我也百度了好几个方案,奈何解决不了,最后 ...
- Office 365管理员设置
一.注册 1.输入网站 http://www.21vbluecloud.com/ ,进入世纪互联蓝云官方网站 2.选择 运营的产品->Office 365 3.选择了解更多 4.浏览根据不同的 ...
- 学习python-20191208(1)-Python Flask高级编程开发鱼书_第03章_数据与flask路由
视频01: 略...... ———————————————————————————————————————————————————————————— 视频02: 搜索需要外部数据源,也就是需要外部的A ...
- TPO1-3 Timberline Vegetation on Mountains
Wind velocity also increase with altitude and may cause serious stress for trees,as is made evident ...
- seek for|contrary to|lag behind|take up|take advantage of|be confident of|allow for |
There are signs ________ restaurants are becoming more popular with families. A. that B. which C. ...
- LeetCode Day 13
LeetCode0026 给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度. 不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空 ...
- 《时间线》:WWT 数字宇宙,虚拟星空
李北辰/文 王尔德说:我们生活在阴沟里,却仍有人仰望星空.如今,这句感叹依旧代表某种程度的正确,但这位19世纪的英国绅士有所不知:在一百多年后的东方"帝都",当困于阴沟中的年轻人们 ...
- 基于Springboot注解的策略模式
释义 策略模式和多态很相似 可以理解为定义了一个统一的接口,有许多不同的实现类,可以自由选择不同的实时类去执行. 实现 上代码: 定义一个统一的接口: [JavaScript] 纯文本查看 复制代码 ...