본문 바로가기
Algorithm/BaekJoon[Java]

백준 1476

by 씨니 2022. 4. 15.
728x90

▶ 1476 문제 - 날짜 계산

- 완전탐색 문제

 

▶ 풀이방법

import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		int E = Integer.parseInt(st.nextToken());
		int S = Integer.parseInt(st.nextToken());
		int M = Integer.parseInt(st.nextToken());
		
		int count = 1;
		int e = 1, s = 1, m = 1;
		while(true) {
			
			if(e > 15) e = 1;
			if(s > 28) s = 1; 
			if(m > 19) m = 1;
			//16 16 16 의 경우 위의 3개의 if문들 거쳐
            //하단의 if문으로 값이 같은지 파악 해야함.
			if(E == e && S == s && M == m) break; 
			e++;
			s++;
			m++;
			count++;
		}
		
		bw.write(String.valueOf(count));
		bw.flush();
		bw.close();
		br.close();
	}
}

 

728x90

'Algorithm > BaekJoon[Java]' 카테고리의 다른 글

백준 6588  (0) 2022.04.07
백준 2004  (0) 2022.04.03
백준 1676  (0) 2022.04.02
백준 11653  (0) 2022.04.02
백준 10872  (0) 2022.04.01