UVALive 4192/HDU 2959 Close Enough Computations 数学
Close Enough Computations

But carefully reading the label may cause the consumer to notice some inconsistencies. A gram of fat has 9 calories, a gram of carbohydrate has 4 calories, and a gram of protein has 4 calories. Consider the label to the right. A simple computation of the number of calories would indicate that the food should contain 12*9 + 31*4 + 5*4 or 252 calories, but the label indicates it has 250 calories.
While sometimes the difference in calories is due to other circumstances (such as the presence of alcohol or soluble fiber), this problem will consider only the possibility of round-off error. This food actually has 12.1 grams of fat (yielding 108.9 calories), 30.6 grams of carbohydrate (122.4 calories), 4.7 grams of protein (18.8 calories), so it does in fact have 250 calories (actually 250.1 calories).
Write a program that will determine if values for a nutritional label are consistent, that is, if there is a way the true values for the grams of nutrients can be rounded to the shown values and yield the number of calories shown.
You should assume that standard rounding rules apply; that is any value less than 0.5 rounds down and those 0.5 or over round up.
End of input is indicated by a line containing 4 zeroes. This line should not be processed.
250 13 31 5
122 10 10 0
0 0 0 0
题意:
给你一个检验值,和三个参数值 这三个参数值 分别*9,*4,*4得到实际值,问你在 参数值可以与实际参数值大小相差在0.5内 的得到的实际值
检验该检验值是否符合标准
题解:
我们把3个参数值都减或加0.5得到最小最大,只要判断 这个需要检验的值是否在 这个范围内就好了
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include<vector>
using namespace std ;
typedef long long ll; const int N = + ;
const int mod = 1e9 + ; int main() {
double sum,a,b,c;
while(~scanf("%lf%lf%lf%lf",&sum,&a,&b,&c)) {
if(sum == && a == && b == && c == )break;
double mi = max((a - 0.5),0.0) * + max((b - 0.5),0.0) * + max((c - 0.5),0.0) * ;
double ma = (a + 0.5) * + (b + 0.5) * + (c + 0.5) * ;
//printf("%lf %lf \n",sum,mi,ma);
if(sum >= mi &&sum <= ma) cout<<"yes"<<endl;
else cout<<"no"<<endl;
}
return ;
}
UVALive 4192/HDU 2959 Close Enough Computations 数学的更多相关文章
- UVALive 4192 Close Enough Computations 水题
Close Enough Computations 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge& ...
- 2017"百度之星"程序设计大赛 - 复赛1003&&HDU 6146 Pokémon GO【数学,递推,dp】
Pokémon GO Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- HDU 5810 Balls and Boxes 数学
Balls and Boxes 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5810 Description Mr. Chopsticks is i ...
- hdu 1577 WisKey的眼神 (数学几何)
WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- hdu - 3959 Board Game Dice(数学)
这道题比赛中没做出来,赛后搞了好久才出来的,严重暴露的我薄弱的数学功底, 这道题要推公式的,,,有类似于1*a+2*a^2+3*a^3+...+n*a^n的数列求和. 最后画了一张纸才把最后的结果推出 ...
- HDU 5902 GCD is Funny 数学
GCD is Funny 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5902 Description Alex has invented a ne ...
- hdu 4946 Just a Joke(数学+物理)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4969 Just a Joke Time Limit: 2000/1000 MS (Java/Others) ...
- HDU 5858 Hard problem (数学推导)
Hard problem 题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5858 Description cjj is fun with ...
- hdu 4497 GCD and LCM 数学
GCD and LCM Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4 ...
随机推荐
- JavaScript的闭包理解
因为本人是做java web 开发的,对js仅仅是存在非常浅的理解,js闭包的概念非常早就听说了,可是一直都不明确是什么意思,今天准备梳理一下闭关的概念; 闭包(closure)是Javascript ...
- poj3685(嵌套二分)
Matrix Time Limit: 6000MS Memory Limit: 65536K Total Submissions: 4658 Accepted: 1189 Descriptio ...
- apiCloud中的数据库操作mcm-js-sdk的使用
1.引入js <!-- 引入mcm-js-sdk Begin --> <script type="text/javascript" src="../pl ...
- FFmpeg 移植 Android
近期项目需要解析苹果的HLS流媒体协议,而FFmpeg从0.11.1“Happiness”版本开始,才增加了对HLS协议的支持.目前网上关于FFmpeg编译移植的文章有很多,但大多都是对旧版本的说明. ...
- Cookie是存储在客户端上的一小段数据
背景 在HTTP协议的定义中,采用了一种机制来记录客户端和服务器端交互的信息,这种机制被称为cookie,cookie规范定义了服务器和客户端交互信息的格式.生存期.使用范围.安全性. 在JavaSc ...
- Python3之时间模块详述
Python3之时间模块 time & datetime & calendar 一. 概述 python 提供很多方式处理日期与时间,转换日期格式是一个常见的功能. 时间元组:很多p ...
- I'm studying Bootstrap! loading...
最近在学习bootstrap框架. Bootstrap框架是目前前端最受欢迎的框架,出于Twitter公司!搞前端你说你不会Bootstrap都不好意思见人呢. Bootstrap是基于Html Cs ...
- ZBrush中Blob点滴笔刷介绍
对于ZBrush®来说,笔刷的使用时至关重要的,ZBrush中给我们提供了越来越多的笔刷的同时,我们也要根据经验来合理选择笔刷.本文内容小编将分享Blob点滴笔刷的简单介绍,该笔刷在使用时笔头犹如一股 ...
- Qwiklab'实验-API Gateway, AWS Lambda'
title: AWS之Qwiklab subtitle: 2. Qwiklab'实验-API Gateway, AWS Lambda' date: 2018-09-20 17:29:20 --- In ...
- BZOJ 2820: YY的GCD 莫比乌斯反演_数学推导_线性筛
Code: #include <cstdio> #include <algorithm> #include <cstring> #include <vecto ...