jumpserver docker-compose deployment file yunson

2023-03-16  

Thinking analysis: 9 -bit integers, consisting of 1 ~ 9 without repeated, pay attention to analyzing without 0.

Each number only appears once, so the smallest number is 123456789, and the largest number is 987654321.

Since it is not repeated, then the 9 numbers can be compared with each one. How to compare, 9 numbers are used in A! = B && A! = C …

Want to put the obtained numbers in the array, and compare the number of numbers by bubbling sorting method. Don’t say that bubbling sort can only be used for sorting …

improvement code can be used.

is not 0 and the numbers are different. After the two conditions are met, they continue to judge.

Use a cycle to judge that the first two are divided by 2, and the top three are divided by 3. …, the top nine are removed by 9. Conditions meet the output and end.

Answer: 381654729

Detailed code is as follows:

public class testlargenumber { 

 /** 
 * @param ARGS 
 */ 
 Public Static Void Main (String [] args) {{ 
 // Todo Auto-Generatd Method Stub 
 int [] wei = new int [9]; // 
 int Flag; 
 int i, num, cNT = 0, n, SUM = 0; // The number of statistics is not equal and 0 

 for (i = 123456789; I <= 987654321; i ++) { 
 num = i; // Initialize num, if I use i directly, it will change later, be careful! 
 Flag = 0; // Used to determine whether to meet the conditions 
 // Calculate each bit 
 for (int j = 0; j <9; j ++) { 
 wei [j] = num % 10; 
 // system.out.println (wei [j]); 
 num = num / 10; 
 } 
 // Judgment is 0 or equal 
 for (int k = 0; k <9; k ++) { 
 if (wei [k] == 0) {{ 
 Flag = 1; 
 Break; 
 } 
 for (int m = k+1; m <9; m ++) { 
 if (wei [k] == wei [m]) {{ 
 Flag = 1; 
 break; // Jump out of the inner cycle 
 } 
 } 
 if (flag == 1) { 
 BREAK; // Jump out of the outer cycle 
 } 
 } 
 // Satisfy none of 0 and each person is not equal, and continue to judge that the first few of them have been removed 
 if (flag == 0) { 
 cNT = 0; // count to 0 to 0 
 SUM = Wei [8]; 
 for (n = 8; n> = 1; n-) { 
 SUM = SUM*10+Wei [n-1]; 
 if (SUM%(10-N) == 0) {{ 
 cNT ++; // Increase 
 } 
 } 
 if (cNT == 8) {// The first 2 digits are divided into the top 9 and 9 are divided into 8. 
 System.out.println (i); // I used i here, and used num to execute 
 } 
 } 
 } 
 // system.out.println (cNT); 
 } 
 }

source

Related Posts

Since the system buffer space is insufficient or the queue is full, the solution to the operation on the socket cannot be performed

Set up LAMP services (Apache, MySQL, PHP)

Package keyword analysis

FLEX layout dictionary

jumpserver docker-compose deployment file yunson

Random Posts

HDP 2.4 offline installation post

Center 7.5 Install Tomcat+JDK+MySQL (Simple Installation of YUM)

Renren Houxun Router TTL flashing

Quartz Deploy Table ‘HeartBeat.qrtzLocks’ DOESN’T Exist

[BZOJ1047] [Monocele] [haoi2007] ideal square