P5727 hail guess

Tip: The main question is with the knowledge of the stack, we can first build a table, and then use a while loop, and then determine odd and even.

Import Classes in java.util *. ;
 public  class the Main {
 public  static  void main (String [] args) {
         // method TODO automatically generated stubs 
     Scanner in = new new Scanner (the System.in);
      int n-in.nextInt = (); // given a positive integer    
     the LinkedList <integer> = List new new the LinkedList <> (); // Create a list     
     the while (n->. 1) // determines the number of parity 
     { 
         list.push (n-); // push 
         IF (n- 2 == 0% ) 
         { 
             n- / = 2 ; 
         }the else 
         { 
             n- * =. 3 ;
              ++ n-; 
         } 
     } 
     list.push ( . 1);
      for ( int I = 0; I <list.size () -. 1; I ++ ) 
     { 
         of System.out.print (List.get ( I) + ""); // number of the list is obtained, and outputs 
     } 
     of System.out.print (List.get (list.size () -1)); // reverse output 
} 
}

 

Guess you like

Origin www.cnblogs.com/coke-/p/12623898.html