Lanqiao Cup official website fill-in-the-blank questions (Formula)

Question description

This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled-in result.

Holmes explores an old castle and sees a strange formula written on the door: ABCDE ∗ ?=EDCBA

He said to Watson: "ABCDE should stand for different numbers, and the question mark should stand for a number!"

Watson: "I guess so!"

So, the two of them were silent for a long time, but still couldn't come up with a suitable result.

Please take advantage of your computer to find the answer to the crack.

Write the numbers represented by ABCDE.

operating restrictions

  • Maximum running time: 1s
  • Maximum running memory: 128M
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        for(int a0=1;a0<=9;a0++){
          for(int a1=0;a1<=9;a1++){
            for(int a2=0;a2<=9;a2++){
              for(int a3=0;a3<=9;a3++){
                for(int a4=0;a4<=9;a4++){
                  for(int a5=1;a5<=9;a5++){
                    if((a0*10000+a1*1000+a2*100+a3*10+a4)*a5==a4*10000+a3*1000+a2*100+a1*10+a0&&
                    a0!=a1&&a0!=a2&&a0!=a3&&a0!=a4&&a1!=a2&&a1!=a3&&a1!=a4&&a2!=a3&&a2!=a4&&a3!=a4){
                      System.out.println(a0*10000+a1*1000+a2*100+a3*10+a4);
                    }
                  }
                }
              }
            }
          }
        }
    }
}

Guess you like

Origin blog.csdn.net/s44Sc21/article/details/132783975