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 ...
随机推荐
- cesium初探之加载三维模型
项目需要用到二三维地图切换,本来准备研究ArcGIS js for Web 3d,但考虑到版权的问题,决定试着用cesium来做,于是花了2天时间抱着试试看的心态把cesium从环境配置到加载三维模型 ...
- UITextView实现PlaceHolder的方式
实现UITextView实现PlaceHolder的方式的方式有两种,这两种方法的核心就是通过通知来添加和去除PlaceHolder:下面来介绍两种方法:个人比较喜欢第一种,看起来更加合理. 方法1: ...
- @EnableGlobalMethodSecurity(prePostEnabled = true)
http://www.bubuko.com/infodetail-2243816.html
- 牛客-小y的盒子
题目传送门 -------------------稍加观察就会发现,4n - 1就是题目要的答案.至于为什么,看官方的题解.不过这个n非常的大,用正常快速幂解决不了.这道题我学到的就是解决幂非常大的情 ...
- 用两个栈实现一个队列(C++)
分析 栈:后进先出 队列:先进先出 要使用两个栈实现队列(先进先出),主要思路是 1.插入一个元素:直接将元素插入stack1即可. 2.删除一个元素:当stack2不为空时 ,直接弹出栈顶元素,当s ...
- NEON优化之《简介》
NDK支持NEON环境配置:https://blog.csdn.net/app_12062011/article/details/50462351 一个很典型的例子:http://hilbert-sp ...
- hadoop报错:could only be replicated to 0 nodes, instead of 1
错误 [root@hadoop test]# hadoop jar hadoop.jarcom.hadoop.hdfs.CopyToHDFS 14/01/26 10:20:00 WARN hdfs.D ...
- Archlinux安装与出现的问题
arch的安装 arch的安装主要参考官网arch wiki,基本上按照Beginners' guide的步骤就可以安装,不过这里推荐用U盘刻录的方法来安装,我尝试过用硬盘安装的办法,还是感觉U盘刻录 ...
- SpringBoot:三十五道SpringBoot面试题及答案
SpringBoot面试前言今天博主将为大家分享三十五道SpringBoot面试题及答案,不喜勿喷,如有异议欢迎讨论! Spring Boot 是微服务中最好的 Java 框架. 我们建议你能够成为一 ...
- log4j.xml配置,包含自定义log4j日志级别及输出日志到不同文件
一.配置 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configura ...