Fifth Blue Bridge Cup Software Category True Questions-C-C-2 magic 6 digits

2022-12-30   ES  

// The Fifth Blue Bridge Cup Software National True True Question-C-C-2_Suki 6 digits 
 /*【topic】 

 Title: Magic 6 digits 

   There is a 6 -bit positive integer, which has a very magical nature: 

   Take it with 2 3 4 5 6, and still get 6 digits. 
   And the number contained in the product is exactly the same as this 6 -digit number! 
   It's just that their order is re -arranged. 

   Please calculate this 6 digits. 

   This is an integer, please submit the answer through the browser, do not fill in any extra content (such as explanatory text) 
 */ 

 /*[Problem Solving Thinking] 
 Solution 1: violent enumeration, and flexibly applied to the underlying labeling to transform into the number of numbers, which has been used several times 
 Answer: 142857 
 */ 

 #include <iostream> 
 #include <cstring> 
 using namespace std; 

 int Visit [10] = {0}; // This variable is used to record the number of times that appears 0 ~ 9, and the number of 0 ~ 9 indicates the number 0 ~ 9 
 int backup [10]; // This variable is used for backup array Visit [] 

 /* 
  * @: Detecting the numbers contained in the number NUM appear in the array backup [] 
  * @Parameter: The detected number num 
  * @Return: If the numbers contained in the detected number num appear in the array backup [], return True, 
  Otherwise, return false 
 */ 
 BOOL Check (int Num) 
 {{ 
 While (num) 
 {{ 
 if (backup [num%10] == 0) 
 Return false; 
 else 
 Backup [num%10]-; // The number of appears decreases by one, 
 // Used to detect a number contained in Num, there are multiple situations 
 num /= 10; 
 } 
 Return true; 
 } 

 int Main () 
 {{ 
 int Num = 100000; 
 int Temp; 
 While (num <1000000) 
 {{ 
 MEMSET (VISIT, 0, SIZEOF (VISIT)); 
 temp = num; 
 
 // Get the numbers on each bit of NUM and the number of occurrences in the array visit [] 
 While (TEMP) 
 {{ 
 visit [temp%10] ++; 
 temp /= 10; 
 } 
 
 BOOL ISSOLUTION = TRUE; 
 for (int i = 2; i <= 6; i ++) 
 {{ 
 memcpy (backup, visit, sizeof (visit); 
 if (! Check (num*i)) 
 {{ 
 IsoLUTION = false; 
 Break; 
 } 
 } 
 if (ISSOLUTION) 
 COUT << "This 6 digits are:" << num << Endl; 
 num ++; 
 } 
 Return 0; 
 }

source

Random Posts

jquery-ui draggable DIV dragging the auxiliary line for easy alignment

rolling wheels prevent the default behavior of rolling parts compatible

virtualbox configuration network and SSH login configuration Oliver

Excel file java simple reading and writing

jtable usage Moon Moon Moon Song