본문 바로가기
알고리즘 & 자료구조/백준

백준 4375_1

by 신재권 2022. 2. 11.
import java.util.Scanner;

public class Main4375_1 {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextInt()) {
			int N = sc.nextInt();
			int num = 0;
			int ans = 1;
			while(true) {
				num = ((num * 10) + 1)%N; //오버플로우 방지 
				if(num == 0) {
					System.out.println(ans);
					break;
				}
				ans++;
			}
		}
	}
	
	
	
}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 1012  (0) 2022.02.13
백준 2178  (0) 2022.02.12
백준 1629  (0) 2022.02.10
백준 3986  (0) 2022.02.09
백준 1940  (0) 2022.02.08