This is the 22nd day of my participation in the Gwen Challenge.[More Challenges]

Hello ah, I am gray little ape, a super will write bug program ape!

Welcome to pay attention to my column “daily Blue bridge”, the main role of this column is to share with you in recent years blue Bridge Cup provincial competition and the final and other real questions, analysis of the existing algorithm ideas, data structure and other content, to help you learn more knowledge and technology!

Title: Sloppy arithmetic

Xiao Ming was a hothead and often copied the teacher’s formulas wrong when he was at school.

Once, the teacher’s topic is: 36 * 495 =?

Instead, he wrote: 396 * 45 =?

But it turned out dramatically that he was right!

Because of the 36 * 495 = 396 * 45 = 17820

There are many similar coincidences, such as 27*594=297*54

Suppose a, B, C, D, and e represent five different numbers from 1 to 9.

How many types of ab * cde = adb * ce?

Please take advantage of the computer to look for all the possibilities and answer the number of types of different formulas.

There are different kinds of equations that satisfy the commutative law of multiplication, so the answer must be an even number

Answers are submitted directly through the browser

Note: submit only one number indicating the number of final statistical categories, and do not submit the solution process or other superfluous content

Answer:

What is the main content of the passage?

Suppose a, B, C, D, and e represent five different numbers from 1 to 9.

How many types of ab * cde = adb * ce?

So we can use enumeration to find all the possible combinations and determine,

At the same time, the number of formulas that meet the requirements can be counted.

Answer source:

Package 2013 Provincial competition Public class Year2013_t3 {/ * * * if a b c d e representative 1 ~ 9 different 5 Numbers (pay attention to the Numbers are different, and do not contain 0) can satisfy the form such as: ab * * ce cde = the adb formula how many kind of like this? * */ public static void main(String[] args) { int count = 0; for (int a = 1; a < 10; a++) { for (int b = 1; b < 10; b++) { if (a! =b) { for (int c = 1; c < 10; c++) { if (c! =a&&c! =b) { for (int d = 1; d < 10; d++) { if (d! =a&&d! =b&&d! =c) { for (int e = 1; e < 10; e++) { if (e! =a&&e! =b&&e! =c&&e! =d) { int x = (a*10+b)*(c*100+d*10+e); int y = (a*100+d*10+b)*(c*10+e); if (x==y) { count++; System.out.printf("(%d*10+%d)*(%d*100+%d*10+%d)==(%d*100+%d*10+%d)*(%d*10+%d)==%d\n",a,b,c,d,e,a,d,b,c,e,x); } } } } } } } } } } System.out.println(count); }}Copy the code

Example output:

There are deficiencies or improvements, but also hope that small partners put forward messages, learn together!

Interested partners can pay attention to the column!

Grey ape accompany you to progress together!