백준 #30224번 Lucky 7

jhj·2024년 2월 4일

백준 JAVA

목록 보기
141/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String n = sc.next();
		
		int i;
		for(i = 0; i < n.length(); i++) {
			if(n.charAt(i) == '7') {
				break;
			}
		}
		
		int num = Integer.parseInt(n);
		if(i == n.length() && num % 7 != 0) {
			System.out.println("0");
		}else if(i == n.length() && num % 7 == 0) {
			System.out.println("1");
		}else if(i != n.length() && num % 7 != 0) {
			System.out.println("2");
		}else if(i != n.length() && num % 7 == 0) {
			System.out.println("3");
		}
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글