POJ-2006 Litmus Test 高精度
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
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
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 高精度的更多相关文章
- POJ 2006:Litmus Test 化学公式
Litmus Test Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 1709 Accepted: 897 Descri ...
- poj 1503 Integer Inquiry (高精度运算)
题目链接:http://poj.org/problem?id=1503 思路分析: 基本的高精度问题,使用字符数组存储然后处理即可. 代码如下: #include <iostream> # ...
- POJ 2084 Catalan数+高精度
POJ 2084 /**************************************** * author : Grant Yuan * time : 2014/10/19 15:42 * ...
- 解方程求PH值,POJ(2006)
题目链接:http://poj.org/problem?id=2006 解题报告: 题意看了半天,没看懂,再加上化学没学好,更加让我头痛. 假设1L溶解了x摩尔的酸:ka=m*x*nx/ori-x; ...
- POJ 1001 解题报告 高精度大整数乘法模版
题目是POJ1001 Exponentiation 虽然是小数的幂 最终还是转化为大整数的乘法 这道题要考虑的边界情况比较多 做这道题的时候,我分析了 网上的两个解题报告,发现都有错误,说明OJ对于 ...
- 【POJ 1001】Exponentiation (高精度乘法+快速幂)
BUPT2017 wintertraining(15) #6A 题意 求\(R^n\) ( 0.0 < R < 99.999 )(0 < n <= 25) 题解 将R用字符串读 ...
- POJ 1625 Censored!(AC自动机+DP+高精度)
Censored! Time Limit: 5000MS Memory Limit: 10000K Total Submissions: 6956 Accepted: 1887 Descrip ...
- POJ 3181 Dollar Dayz(高精度 动态规划)
题目链接:http://poj.org/problem?id=3181 题目大意:用1,2...K元的硬币,凑成N元的方案数. Sample Input 5 3 Sample Output 5 分析: ...
- poj 2773 Happy 2006 - 二分答案 - 容斥原理
Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 11161 Accepted: 3893 Description Two ...
随机推荐
- PHP7.1.X+wordpress+windows,安装Memcached服务
1.下载安装Memcached 64位系统1.4.4版本:memcached-win64-1.4.4-14.zip 2.解压缩在任意盘符,然后进入文件夹,在文件夹中运行CMD输入以下命令: 1)输入 ...
- efcore adddbcontext
public static IServiceCollection AddDbContext<TContextService, TContextImplementation>( [NotNu ...
- 前端之本地存储和jqueryUI
本地存储 本地存储分为cookie,以及新增的localStorage和sessionStorage 1.cookie 存储在本地,容量最大4k,在同源的http请求时携带传递,损耗带宽,可设置访问路 ...
- C# shell32.dll 的用法
1 首先要使用shell32 请在项目引用中添加shell32.dll 的引用 (备注:该引用是系统dll文件 在C:\Windows\System32 目录下 可以自行拷贝到项目中) priv ...
- 无法打开锁文件 /var/lib/dpkg/lock-frontend - open
转自:https://blog.csdn.net/sinat_29957455/article/details/89036005 在使用apt-get安装程序的时候报: E: 无法打开锁文件 /var ...
- Javase之多线程(2)
多线程(2) 线程的生命周期 新建:创建线程对象 就绪:有执行资格,没有执行权 运行:有资格运行,有执行权 阻塞:由一些操作让线程处于改状态.没有执行资格,没有执行权,而通过另一些操作激活它,激活 ...
- Linux常见目录说明
常见目录说明 目录 应放置档案内容 /bin/ 存放二进制可执行文件,系统的命令(ls,cat,mkdir等),是/usr/bin/目录的软链接. /sbin/ 存放系统命令,超级用户可以执行.是/u ...
- emmet的用法
emmet 是一个提高前端开发效率的一个工具.emmet允许在html.xml.和css等文档中输入缩写,然后按tab键自动展开为完整的代码片段. 一.Sublime Text 3 安装插件Emmet ...
- 字符串和id的转换方法
在项目中经常会遇到一个需求就是字符串和id的转换,比如标签和标签id.因为在存储系统里面存储字符串会比较浪费内存,而存储id会节省内存和提高效率. 问题分解 通过字符串获得id 通过id获得字符串 实 ...
- Oracle 导入dmp 故障存储文件
创建表空间及用户CREATE TABLESPACE OracleDBFDATAFILE 'D:\app\zhoulx\oradata\bdc\OracleDBF.DBF' SIZE 100M AUTO ...