2 shunfurh shunfurh 于 2017.09.05 19:33 提问

Calories from Fat

Fat contains about 9 Calories/g of food energy. Protein, sugar, and starch contain about 4 Calories/g, while alcohol contains about 7 Calories/g. Although many people consume more than 50% of their total Calories as fat, most dieticians recommend that this proportion should be 30% or less. For example, in the Nutrition Facts label to the right, we see that 3g of fat is 5% of the recommended daily intake based on a 2,000 calorie diet. A quick calculation reveals that the recommended daily intake of fat is therefore 60g; that is, 540 Calories or 27% Calories from fat.

Others recommend radically different amounts of fat. Dean Ornish, for example, suggests that less than 10% of total caloric intake should be fat. On the other hand, Robert Atkins recommends the elimination of all carbohydrate with no restriction on fat. It has been estimated that the average Atkins dieter consumes 61% of Calories from fat.
From a record of food eaten in one day, you are to compute the percent Calories from fat. The record consists of one line of input per food item, giving the quantity of fat, protein, sugar, starch and alcohol in each. Each quantity is an integer followed by a unit, which will be one of: g (grams), C (Calories), or % (percent Calories). Percentages will be between 0 and 99. At least one of the ingredients will be given as a non-zero quantity of grams or Calories (not percent Calories).


Input will consist of several test cases. Each test case will have one or more lines as described above. Each test case will be terminated by a line containing '-'. An additional line containing '-' will follow the last test case.


For each test case, print percent Calories from fat, rounded to the nearest integer.

Sample Input

3g 10g 10% 0g 0g

55% 100C 0% 0g 30g

25g 0g 0g 0g 0g

1g 15% 20% 30% 1C

Sample Output



caozhy   Ds   Rxr 2017.09.19 23:52
Csdn user default icon
(学习个输出方法)POJ 1929 Calories from Fat(没啥算法,就是比较复杂还有个输出问题)
题意:每天人都要摄入各种食物,然后每种食物,可能含有脂肪,蛋白质,盐,淀粉,酒精这些东西的一种或者几种。然后求出每日从这些食物中从脂肪中摄取的卡路里的总数占每天摄入的所有卡路里总数的百分比。注意要四舍五入输出。 分析:没啥算法,思路就是求出所有的的脂肪卡路里和所有的卡路里,然后求就行。 注意的东西:如何控制输入输出的格式,如何控制四舍五入   控制四舍五入的几种方法: 1.#include #
poj 1929 Calories from Fat 模拟水题
//poj 1929 //sep9 #include using namespace std; double tot,fat; char s[5][128]; void get_value(int i,double &v,int &tag) { int p=0; v=0; while(s[i][p]='0') v=10*v+s[i][p]-'0',++p; if(s[i][p]==
POJ 1929 Calories from Fat 笔记
找到Build settings->Linking->Other Linker Flags,将此属性修改成-all_load
这是我的第一篇文章,同时也记录着我在读研时候的点点滴滴,从12月17日开始~KMeans+DBSCAN算法 KmeansKMeans算法是一种聚类算法,而聚类问题在机器学习中主要是是一类无监督问题:简单理解是手中无标签,我们要去分出标签。这类问题的难点是:如何去评估,也就是怎么来评估我们算法的好坏。如何调参?也就是到底有多少个聚类中心点。 KMeans最大的问题就是一个先验知识,这个先验知识是让我
Fat Jar Eclipse Plug-In教程
Fat Jar Eclipse Plug-In教程安装:---------------zip文件含有插件目录的,把fatjar.jar放入eclipse的插件目录下.关闭 eclipse. 以eclipse -clean命令从命令行启动 eclipse 否则发现不了插件.删除:只要在eclipse的插件目录下移出net.sf.fjep.fatjar_x.x.x即可该开源项目见:http:/
android fat-aar.gradle中文注释
/** * This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or
蓝桥杯-嵌入式交流群 147520657 经过充分的研究,发现fatfs文件系统移植的比较简单!因为代码都已经被别人做好了!我们只需把io层稍稍做个处理就ok了; http://elm-chan.org/fsw/ff/00index_e.html 这个网站发布了所有版本的文件fatfs文件系统,我这次下载最新版的http://elm-chan.org/fsw/ff/ff9a.zip 直接解压,里面有两个文件,一个是src,另一个是doc;
import static java.util.Comparator.comparingInt; import static java.util.stream.Collectors.collectingAndThen; import static java.util.stream.Collectors.counting; import static java.util.stream.Coll
Fat Jar Eclipse Plug-In Current Release: alpha Url Update Manager: http://kurucz-grafika.de/fatjar Download from: project page Requirements:  Eclipse 3.0 or g