Judge Info

  • Memory Limit: 32768KB
  • Case Time Limit: 5000MS
  • Time Limit: 5000MS
  • Judger: Float Numbers (1e-4) Judger

Description

The chemists are well known because of their weird. Especially when they add water or salt in the same beaker over and over again. Moreover, the still hope you can tell him the mass fraction of the liquor after many operations. In case of your forgetting your junior school chemistry class, now we particularly give you the formula of the mass fraction.

w=a/(a+b)×100% here w means the mass fraction, a means the mass of the salt, and b means the mass of water.

Input

The first line contains two integers, representing the mass of water and salt initially. Than each line will represent a operation. The operation contains:

  • 1. To add some salt into the beaker, the code is "salt x". x is a float number meaning the measure of salt The chemists add
  • 2. To add some water into the beaker, the code is "water x". x is a float number meaning the measure of water The chemists add
  • 3. Showing the mass fraction currently and the code is "show".
  • 4. Exit the test. The code is "exit".

The number will not be larger than 1e9.

Output

Output should be according to the operation. Print the mass fraction of the liquor. All the answer has an absolute error within 1e-4, will be consider as correct answer.

Sample Input

1.5 0.5
salt 0.5
water 1.5
show
exit

Sample Output

0.25

解题思路:printf("%g\n", a/sum);  %g 指省略后面所有无效的0。 虽然这题很简单,但是每一道水题都要认真对待并且总结。

 #include <stdio.h>
#include <string.h> char A[]; int main()
{
float a,b,sum,c,d;
scanf("%f%f",&b,&a);
while(){
memset(A,'\0',sizeof(A));
scanf("%s", A);
if(strcmp(A,"salt")==){
scanf("%f",&c);
a+=c;
continue;
}
if(strcmp(A,"water")==){
scanf("%f",&d);
b+=d;
continue;
}
if(strcmp(A,"show")==){
sum=a+b;
printf("%g\n", a/sum);
continue;
}
if(strcmp(A,"exit")==){
break;
} }
return ;
}

SZU:G32 Mass fraction的更多相关文章

  1. R语言学习

    1.清屏 Ctrl + L 2.退出 q() 3.设置工作空间 getwd() setwd('D:\\Program Files\\RStudio\\workspace') 4.显档当前工作目录下的文 ...

  2. jet flow in a combustion chamber

    Table of Contents 1. contacts 2. Paper digest 2.1. LES vs. RANS 2.2. Dynamics of Transient Fuel Inje ...

  3. FLUENT质量加权平均和面积加权平均的区别【转载】

    转载自:http://blog.sina.com.cn/s/blog_7ef78d170101bhfn.html 网上关于fluent中质量加强平均(Mass-Weighted Average)和面积 ...

  4. Usage of hdf2v3 and hdf2file

    备注 修改Filetype,再执行hdf2file或hdf2tab,可以输出不同类型的数据.把Filetype设置成8,就是 Tecplot 格式的数据. <!DOCTYPE html PUBL ...

  5. Journal of Proteome Research | Prediction of an Upper Limit for the Fraction of Interprotein Cross-Links in Large-Scale In Vivo Cross-Linking Studies (分享人:张宇星)

    题目:Prediction of an Upper Limit for the Fraction of Interprotein Cross-Links in Large-Scale In Vivo ...

  6. 新手!mass 设置问题

    mass就是你那个物体的质量啊质量越大,惯性也越大重力也越大.假如你的刚体的mass为1,那么你只要给这个物体9.81N向上的力,你就可以抵消重力,让这个物体悬浮着:但假如这个物体的mass为10,你 ...

  7. [LeetCode] Fraction to Recurring Decimal 分数转循环小数

    Given two integers representing the numerator and denominator of a fraction, return the fraction in ...

  8. How to: Change Sales Rep/Team via Mass Update

    /* from: https://netsuite.custhelp.com/app/answers/detail/a_id/30057/kw/reassign%20sales */ How to c ...

  9. Fraction to Recurring Decimal

    Given two integers representing the numerator and denominator of a fraction, return the fraction in ...

随机推荐

  1. 微信QQ的二维码登录原理浅析

    在非常多地方就是都出现了使用二维码登录,二维码付款,二维码账户等应用(这里的二维码种马,诈骗就不说了),二维码验证,多终端辅助授权应用開始多起来,这里先说下啥是二维码,事实上二维码就是存了二进制数据的 ...

  2. TCP/IP的经典网络编程

                                                                             TCP/IP网络编程之四书五经             ...

  3. SSH框架总结(帧分析+环境结构+示例源代码下载)

    首先,SSH不是一个框架.而是多个框架(struts+spring+hibernate)的集成,是眼下较流行的一种Web应用程序开源集成框架,用于构建灵活.易于扩展的多层Web应用程序. 集成SSH框 ...

  4. c#有关udp可靠传输(包传输数据包) 升级

    在c#有关udp可靠传输(包传输数据包)我们讨论,UDP包的发送,可是上一个程序有一个问题.就是数据比較大.一个Message类序列化后都有2048B,而实际的数据量也就只是 50B罢了,这就说明当中 ...

  5. js 正则学习小记之匹配字符串优化篇

    原文:js 正则学习小记之匹配字符串优化篇 昨天在<js 正则学习小记之匹配字符串>谈到 个字符,除了第一个 个,只有 个转义( 个字符),所以 次,只有 次成功.这 次匹配失败,需要回溯 ...

  6. 使用ArcGIS API for Silverlight + Visifire绘制地图统计图

    原文:使用ArcGIS API for Silverlight + Visifire绘制地图统计图 最近把很久之前做的统计图又拿出来重新做了一遍,感觉很多时候不复习,不记录就真的忘了,时间是最好的稀释 ...

  7. 利用webBrowser获取框架内Html页面内容

    原文:利用webBrowser获取框架内Html页面内容 利用webBrowser获取页面比较简单,MSDN下有示例,在这里不必多说. 可是一些 HTML 文档由“框架”构成,或可以存放它们自己独特 ...

  8. C#特性和反射

    C#特性和反射 .NET编译器的任务之一就是为所有定义和引用的类型生成元数据描述.除了程序集中标准的元数据外,.NET平台还支持特定(attribute)把更多的元数据嵌入到程序集中. .NET特性扩 ...

  9. 关于小改CF协同过滤至MapReducer上的一些心得

    至上次重写ID3 MR版之后,手贱继续尝试CF.之前耳闻CF这两年内非常火,论内某大神也给了单机版(90%代码来自于其).所以想试试能否改到MR上.整体来说,CF本身的机制以相似性为核心,与迭代调用几 ...

  10. MongoDB学习笔记&lt;两&gt;

    继续有shell学问,他们继续研究的例子,下面的知识: --文档数据插入 --文档数据删除 --文档数据更新 如下面的详细信息: 1.插入文档 db.person.insert({"name ...