-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExam19_6190.java
More file actions
40 lines (35 loc) · 983 Bytes
/
Exam19_6190.java
File metadata and controls
40 lines (35 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Exam19_6190 {
static int N;
static int score = 0;
//시작값이 홀수면 숫자 * 3 + 1
//짝수면 나누기 2
//반복하여 N이 1이될때까지 score++
//최종 score값 출력
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
while (N != 1) {
ACNGame();
}
System.out.println(score);
}
public static void ACNGame(){
if(checkOddEven(N)==1){
N = N * 3 + 1;
}else{
N = N / 2;
}
score++;
}
public static int checkOddEven(int n){
if(n%2==1){
return 1;
}else{
return 0;
}
}
}