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. Jenkins 插件 升级站点 镜像 好用的 2019年11月

    这两天开始学Jenkins 用docker下载了一个镜像运行 , 版本太老了.初始化插件各种报错:版本低/ 更新失败等. dockerhub里面的版本才 2.60 然后又从Jenkins.io 官网上 ...

  2. 【linux】linux命令--uptime查看机器存活多久和平均负载 解读平均负载含义

    一.uptime命令,查看机器存活时间和平均负载 键入命令: uptime 该结果和 top命令查看结果最上面一行的 是一样的显示. 返回数据介绍: #当前服务器时间: 19:56:44 #当前服务器 ...

  3. SEH hook 的一种方法

    Windows内核分析索引目录:https://www.cnblogs.com/onetrainee/p/11675224.html 技术学习来源:火哥(QQ:471194425) 该方法的一些原理暂 ...

  4. springmvc学习笔记二:重定向,拦截器,参数绑定

    Controller方法返回值 返回ModelAndView controller方法中定义ModelAndView对象并返回,对象中可添加model数据.指定view. 返回void 在Contro ...

  5. webpack管理资源(loader操作)

    1.加载css npm install --save-dev style-loader css-loader webpack.config.js文件中: const path = require('p ...

  6. 剑指offer 12:二进制中1的个数

    题目描述 输入一个整数,输出该数二进制表示中1的个数.其中负数用补码表示. 解法一:设置标志为flag=1,逐个位移至不同位置,比较是否为1. C++实现 class Solution { publi ...

  7. 深入理解JVM虚拟机(二):JDK 内存类的异常分析

    JVM数据存储 堆存储(Heap):对象存储,实际上就是JAVA的数据存储 方法堆栈(Method Stack):存储方法调用的关系. 永久代(Perm):在JDK1.6及之前,常量数据存储于此区域 ...

  8. 软件工程基础团队第二次作业(团队项目-需求分析&系统设计)成绩汇总

    一.作业题目 团队第二次作业:需求分析&系统设计 二.具体要求 1.作业任务 任务一:组长组织项目组开展需求调研工作(可采取需求调查.问卷.分析已有软件.网上资料等方法).概要设计.详细设计. ...

  9. 【bzoj1997】[Hnoi2010]Planar(平面图+2-sat)

    传送门 几乎和这个题一样,就不说题意了,比较特殊的点就是,这里有个结论: 平面图的边数\(m<3n-6\),\(n\)为点数. 所以我们可以通过这个减枝,\(m\)较大时直接输出\(no\).小 ...

  10. 7. Vue - 组件

    一.组件分类 1. 定义 ​ 组件是可以扩展HTML元素,封装可重用的代码.在较高层面上,组件是自定义元素.特点为:代码重用,提高开发效率,让网页结构更清晰. 2. 局部组件 ​ 只能在定义它的el中 ...