Topic:
When he was in elementary school, Xiaoming often invented his own new algorithm. Once, the teacher's topic is:
1/4 times 8/5 Xiao Ming incredibly put the molecules together, the denominator stitching together, the answer is: 18/45
The teacher was just trying to criticize him, and then he thought, the answer happened. For the numerator and denominator are all one-digit numbers in the 1~9, what other formulas can be computed like this?
Please write down the number of all the different formulas (including examples in the question).
Obviously, after the numerator's denominator, for example: 4/1 times 5/8 is satisfying, this is a different formula.
But for the same numerator denominator, 2/2 times 3/3 has too many types, not counting! Note: The answer is an integer (consider symmetry, which is definitely even). Please submit via browser. Don't write extra content.
The answers are as follows:
Public classStrange fraction { Public Static void Main(string[] args) {intCount =0; for(intA =1; A <=9; a++) { for(intb =1; b <=9; b++) {if(A! = b) { for(intc =1; C <=9; C + +) { for(intD =1; D <=9; d++) {if(c! = d) {//Must be aware of the type selection, should not use int type, longitude too low should use double DoubleSUM1 = (Double) A/b * C/D;DoubleSum2 = (Double) (A *Ten+ c)/(b *Ten+ D);if(sum1 = = sum2) {count++; } } } } } } } System. out. println (count); }}
The result is: 14
Java algorithms-odd fractions