NYOJ题目11613n+1问题

------------------------

纯纯的模拟

AC代码:

 1 import java.io.BufferedReader;
 2 import java.io.IOException;
 3 import java.io.InputStreamReader;
 4 
 5 public class Main {
 6 
 7     public static void main(String[] args) throws IOException {
 8         
 9         BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
10         
11         boolean first=true;
12         while(first || reader.ready()){
13             first=false;
14             long n=Long.parseLong(reader.readLine());
15             System.out.println(solve(n)%3);
16         }
17         
18     }
19     
20     public static int solve(long n){
21         int res=0;
22         while(n>1){
23             n=n/2*2==n?n/2:n*3+1;
24             res++;
25         }
26         return res;
27     }
28     
29 }

题目来源: http://acm.nyist.net/JudgeOnline/problem.php?pid=1161

原文地址:https://www.cnblogs.com/cc11001100/p/5879412.html