Title Description:
Title: The odd fraction
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 actually put the molecules together, the denominator stitching together, the answer is: 18/45 (see figure 1.png)
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 an even number). Please submit via browser. Don't write extra content.
Program code:
#include <stdio.h>
#include <math.h>
int count;//for statistic count
Error
#define EPS 10e-10
int main () {
int i,j,m,n;
for (i = 1;i<=9;++i) {
for (j = 1;j<=9;++j) {
for (m=1;m<=9;++m) {
for (n=1;n<=9;n++) {
if ((i==j) | | | (m==n)) Continue
if (Fabs (i*10+m) *1.0/(j*10+n)-(i*m*1.0)/(j*n)) <eps) {//Plus and multiply do absolute comparisons
count++;
}
}
}
}
}
printf ("%d", count);
return 0;
}
Final results: 14
2014 The fifth session of the Blue Bridge Cup test-C + + program Design Group B-Strange fraction