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

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.

Output

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

Sample Input

3g 10g 10% 0g 0g

## 1g 15% 20% 30% 1C

Sample Output

53%
100%
32%

1个回答

caozhy      2017.09.19 23:52

（学习个输出方法）POJ 1929 Calories from Fat(没啥算法，就是比较复杂还有个输出问题)

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 笔记

KMeans+DBSCAN小试

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:/