SZU:G32 Mass fraction
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的更多相关文章
- R语言学习
1.清屏 Ctrl + L 2.退出 q() 3.设置工作空间 getwd() setwd('D:\\Program Files\\RStudio\\workspace') 4.显档当前工作目录下的文 ...
- 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 ...
- FLUENT质量加权平均和面积加权平均的区别【转载】
转载自:http://blog.sina.com.cn/s/blog_7ef78d170101bhfn.html 网上关于fluent中质量加强平均(Mass-Weighted Average)和面积 ...
- Usage of hdf2v3 and hdf2file
备注 修改Filetype,再执行hdf2file或hdf2tab,可以输出不同类型的数据.把Filetype设置成8,就是 Tecplot 格式的数据. <!DOCTYPE html PUBL ...
- 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 ...
- 新手!mass 设置问题
mass就是你那个物体的质量啊质量越大,惯性也越大重力也越大.假如你的刚体的mass为1,那么你只要给这个物体9.81N向上的力,你就可以抵消重力,让这个物体悬浮着:但假如这个物体的mass为10,你 ...
- [LeetCode] Fraction to Recurring Decimal 分数转循环小数
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
- 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 ...
- Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in ...
随机推荐
- 《Java并发编程实战》第十四章 构建自己的同步工具定义 札记
一.状态依赖性的管理 有界缓存实现的基类 @ ThreadSafe public abstract class BaseBoundedBuffer<E> { @GuardeBy( &quo ...
- lucene两个分页操作
基于lucene两个分页: lucene3.5查询方式(每次查询所有记录,然后取当中部分记录.这样的方式用的最多),lucene官方的解释:因为我们的速度足够快. 处理海量数据时.内存easy内存溢出 ...
- 网络资源(6) - EJB视频
2014_08_24 http://v.youku.com/v_show/id_XMjE0NjE3MDA0.html?f=5227828 01_EJB3.0_下载安装与运行jboss -------- ...
- 【C++基础】类的组合
所谓类的组合是指:类中的成员数据是还有一个类的对象或者是还有一个类的指针或引用.通过类的组合能够在已有的抽象的基础上实现更复杂的抽象. 比如: 1.按值组合 #include<iostream. ...
- lua for通过循环table一些差异
有两个著名的是:ipairs和pairs,双方都认为,我们都非常熟悉的.其中ipairs刮(idx=1)从明年序遍历,经验nil那退出循环:和pairs遍历,仅仅要里面有值都能够遍历的到. 那假如我须 ...
- RHEL5 X86-64上安装Oracle 11gR2演示样例与总结
进入Oracle DBA行业也有好几年了,可是说到安装Oracle的经验,我还真不是特别多,印象中刚開始每次安装都有点磕磕碰碰,随着接触Oracle的时间越来越长,各方面的原理.机制也都有一定的了解后 ...
- FindBugs:Compiler output path for module can not be null. check your module/project settings问题原因
这可能是很多人在使用Android studio 该插件会发现此错误信息:Compiler output path for module can not be null. check your mod ...
- SQL Server 得到SPID,唯一的sessionID
像.net中的session一样,假设能知道了数据库中的sessionID,那全部的操作都能知道了,由于有了这个唯一的身份识别的标识. 能够做的事情有非常多,如:当前哪个用户在做什么操作,在运行什么s ...
- MVC 发布到 windows2003遇到 'System.Web.WebPages.Razor 错误提示
摘自: http://blog.csdn.net/lanqiao825/article/details/7840606 http://bbs.maticsoft.com/forum.php?mod=v ...
- unity多边形uv地图
我曾经写过一篇文章,不规则图形uv地图.(http://blog.csdn.net/itolfn/article/details/17240131)我用三角算法.但是,这种方法已经不完全,有一个指明: ...