본문 바로가기
Coding Test/백준

[백준 1110번 - java] 더하기 사이클

by olli2 2021. 11. 4.

https://www.acmicpc.net/problem/1110

 

내 답안

import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner s = new Scanner(System.in);
		int first = s.nextInt();
		int N = first;
		int cnt = 0;
		
		while(true) {
			N = (10 * (N%10)) + ((N/10) + (N%10))%10;
			cnt++;
			if (first == N) break;
		}
		System.out.println(cnt);
	}
}