Basic exercises special palindrome
Resource constraints
Time limit: 1.0s Memory Limit: 512.0MB
Problem Description
123321 is a very special number, it is read and read from the right as from the left.
Enter a positive integer n, find all such programming five and six decimal numbers, figures and meet all equal to n.
Input Format
Input line, contains a positive integer n.
Output Format
In ascending order of the output integer satisfying the condition, one row each integer.
Sample input
52
Sample Output
899998
989989
998899
Scale data and conventions
1<=n<=54。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int number=scanner.nextInt();
for (int i = 10000; i < 100000; i++) {
int a=i/10000;
int b=i%10000/1000;
int c=i%10000%1000/100;
int d=i%10000%1000%100/10;
int e=i%10000%1000%100%10;
if(a==e && b==d && a+b+c+d+e==number){
System.out.println(i);
}
}
for (int i = 100000; i < 1000000; i++) {
int a=i/100000;
int b=i%100000/10000;
int c=i%100000%10000/1000;
int d=i%100000%10000%1000/100;
int e=i%100000%10000%1000%100/10;
int f=i%100000%10000%1000%100%10;
if(a==f && b==e && c==d && a+b+c+d+e+f==number){
System.out.println(i);
}
}
}
}