The pH scale measures the concentration of protons (H +) in a solution and, therefore, its acidity or alkalinity. The pH value of a solution is a number between 0 and 14; it is less than 7 if the solution is acidic, greater than 7 if the solution is basic, and 7 if it is neutral.

The formula for calculating pH is

pH = -log
10 [H
+]

where [H
+] is the concentration of protons measured in moles per litre.

To calculate the pH value of an acid, one has to determine
the concentration of protons in the solution. When an acid is dissolved
in water, an equilibrium is reached and is governed by the equation

K
a = [H
+] [acid ions] / [acid]

where K
a is the acidity constant (known for each acid), [acid
ions] is the concentration of the acid ions that have dissolved, and
[acid] is the concentration of the undissolved acid. Before the acid is
added, both [H
+] and [acid ions] are assumed to be 0.

For example, the acidity constant of methanoic acid is 1.6 * 10
-4. Dissolving one mole of acid molecules results in one mole of H
+ and one mole of acid ions. If the initial
concentration of the methanoic acid is 0.1 moles/L and x moles of acid
are dissolved (per liter), then the final concentration at equilibrium
would be 0.1 - x moles/L for the acid and x moles/L for H
+ and the acid ions.

Input

The input consists of a number of test cases. Each test case
contains 4 numbers on a line: two positive floating-point numbers
specifying the acidity constant K
a and the original concentration of the acid (in
moles/liter) added to the water, as well as two positive integers m and n
indicating that each mole of acid molecules is dissolved into m moles
of H
+ ions and n moles of acid ions. The floating-point
numbers are specified in scientific notation as shown below. The input
is terminated with a line containing four zeros.

Output

For each test case, print on a line the pH value of the solution, rounded to 3 decimal places.

Sample Input

1.6e-04 1.0e-01 1 1
1.6e-04 1.0e-01 4 1
1.5e-05 5.0e-02 1 2
0 0 0 0

Sample Output

2.407
2.101
3.216 OJ-ID:
POJ-2006 author:
Caution_X date of submission:
20190929 tags:
卡常的水题 description modelling:
给定电离平衡常数Ka,溶液未电离时的浓度C,1mol 酸的氢含量n和酸根含量m major steps to solve it:
    常规化学题的推导:设[H+]=x,[酸根]=y,则Ka=x*y/(C-y),x/y=n/m.
    记Ka=a,C=b,解得:ans=(-log10((-a+sqrt(a*a+(4.0*a*b*n*m)))/(2.0*m))). warnings:
sqrt(n/m)会导致精度不足,用sqrt(n*m)/m来替代则AC AC CODE:
#include<iostream>
#include<cmath>
#include<iomanip>
#include<cstdio>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
double a,b;
int n,m;
while(~scanf("%lf%lf%d%d",&a,&b,&n,&m)&&a&&b&&n&&m)
{
cout<<setprecision()<<fixed<<(-log10((-a+sqrt(a*a+(4.0*a*b*n*m)))/(2.0*m)))<<endl;
}
return ;
}

POJ-2006 Litmus Test 高精度的更多相关文章

  1. POJ 2006:Litmus Test 化学公式

    Litmus Test Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 1709   Accepted: 897 Descri ...

  2. poj 1503 Integer Inquiry (高精度运算)

    题目链接:http://poj.org/problem?id=1503 思路分析: 基本的高精度问题,使用字符数组存储然后处理即可. 代码如下: #include <iostream> # ...

  3. POJ 2084 Catalan数+高精度

    POJ 2084 /**************************************** * author : Grant Yuan * time : 2014/10/19 15:42 * ...

  4. 解方程求PH值,POJ(2006)

    题目链接:http://poj.org/problem?id=2006 解题报告: 题意看了半天,没看懂,再加上化学没学好,更加让我头痛. 假设1L溶解了x摩尔的酸:ka=m*x*nx/ori-x; ...

  5. POJ 1001 解题报告 高精度大整数乘法模版

    题目是POJ1001 Exponentiation  虽然是小数的幂 最终还是转化为大整数的乘法 这道题要考虑的边界情况比较多 做这道题的时候,我分析了 网上的两个解题报告,发现都有错误,说明OJ对于 ...

  6. 【POJ 1001】Exponentiation (高精度乘法+快速幂)

    BUPT2017 wintertraining(15) #6A 题意 求\(R^n\) ( 0.0 < R < 99.999 )(0 < n <= 25) 题解 将R用字符串读 ...

  7. POJ 1625 Censored!(AC自动机+DP+高精度)

    Censored! Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 6956   Accepted: 1887 Descrip ...

  8. POJ 3181 Dollar Dayz(高精度 动态规划)

    题目链接:http://poj.org/problem?id=3181 题目大意:用1,2...K元的硬币,凑成N元的方案数. Sample Input 5 3 Sample Output 5 分析: ...

  9. poj 2773 Happy 2006 - 二分答案 - 容斥原理

    Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 11161   Accepted: 3893 Description Two ...

随机推荐

  1. Docker学习——基本使用

    最近公司项目要用docker部署,第一次接触,记录一下,方便使用时查阅. 你有没有遇到过这种情况,在本地运行良好的代码,在另一台电脑或者另一个环境里一堆bug,可以说是水土不服,本质上是两个电脑的运行 ...

  2. Spring Boot2 系列教程(二十二)整合 MyBatis 多数据源

    关于多数据源的配置,前面和大伙介绍过 JdbcTemplate 多数据源配置,那个比较简单,本文来和大伙说说 MyBatis 多数据源的配置. 其实关于多数据源,我的态度还是和之前一样,复杂的就直接上 ...

  3. 做一个vue轮播图组件

    根据huangyi老师的慕课网vue项目跟着做的,下面大概记录了下思路 1.轮播图的图 先不做轮播图逻辑部分,先把数据导进来,看看什么效果.在recommend组件新建一个recommends的数组, ...

  4. 真机调试(A valid provisioning profile for this executable was not found.)

    这个问题是因为provisioning的问题,因为真机没有加入到账号下面的原因 解决步骤 1.吧identifier复制然后再平开开发中心 2.点击+号添加设备保存 3.在develope中选中保存即 ...

  5. Qt开源编辑器qsciscintilla的一些用法

    首先放一张自己做的软件中的编辑器的效果图 中间红色的框就是放在Qt的tabwidget控件中的qsciscintilla编辑器 先从官网下载qsciscintilla源码,在qtcreater中编译, ...

  6. [b0020] python 归纳 (六)_模块变量作用域

    test_module2.py: # -*- coding: utf-8 -*-"""测试 模块变量的作用域 总结:1 其他模块的变量,在当前模块的任何地方,包括函数都可 ...

  7. Angular 学习笔记(二)

    控制器: 就像 JavaScript 里的构造函数一般,用来增强作用域(scope),当一个控制器通过 ng-controller 指令来添加到 DOM 中时, ng 会调用该控制器的构造函数来生成一 ...

  8. Linux下迅速删除一个大文件夹

    rsync -av --delete /tmp/null/ ./        迅速删除大文件夹,如缓存 快速删除大目录(即大量文件)1.先建立一个空目录 mkdir /data/blank 2.用r ...

  9. C++踩坑——用memset对vector进行初始化

    在一段程序中,使用memset对vector进行了初始化,然后得到了错误的结果.找这个bug花费了很长时间. vector中有其自身的结构,不能单纯的按字节进行初始化.使用memset对vector进 ...

  10. ipvsadm用法

    其实LVS的本身跟iptables很相似,而且连命令的使用格式都很相似,其实LVS是根据iptables的框架开发的,那么LVS的本身分成了两个部分: 第一部分是工作在内核空间的一个IPVS的模块,其 ...