Zoj 2351
Litmus test
This question is the key, and I remember the chemistry knowledge about the Ionization Equilibrium Constant in the third year of my heart and lungs. Then I think of the root equation of the quadratic equation, and I can finally do it.
The four numbers are Ionization Equilibrium Constants, initial concentrations, which are several yuan of acid. An acid molecule separates several acid ions, then, the concentration of the dissolved and undissolved parts is calculated based on the question. Well.
The code and precautions are as follows:
# Include <stdio. h> # include <math. h> int main () {int N, I, j, m, n; double K1, K2, pH, X; scanf ("% d", & N ); for (I = 1; I <= N; I ++) {getchar (); For (j = 1; j ++) {scanf ("% lf", & K1, & K2); // the receipt of scientific notation is the same as that of the double type. Scanf ("% d", & M, & N ); if (k1 = 0 & k2 = 0 & M = 0 & n = 0) break; X = (SQRT (K1 * k1 + 4 * m * n * K1 * K2)-k1)/2/N; ///// the plus and minus signs of the formula must be carefully written to the pH =-1 * log (X)/log (10); printf ("%. 3lf \ n ", pH);} if (I! = N) printf ("\ n");} return 0 ;}