백준 #31613번 繰り返し (Repetition)

jhj·2024년 5월 20일

백준 JAVA

목록 보기
478/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int n = sc.nextInt();
		int count = 0;
		
		while(x < n) {
			if(x % 3 == 0) {
				x++;
			}else if(x % 3 == 1) {
				x = x * 2;
			}else if(x % 3 == 2) {
				x = x * 3;
			}
			count++;
		}
		System.out.println(count);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글