슈콩

[BOJ] 백준 1476 날짜 계산 본문

Algorithms/Baekjoon

[BOJ] 백준 1476 날짜 계산

shukong 2025. 9. 10. 15:23

[문제]

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

 

 

[소스 코드]

import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	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 e = 1; int s = 1; int m = 1;
    	int year = 1;
    	while(!(E==e && S==s && M==m)) {
    		e++; 
    		if(e%16==0) {
    			e = 1;
    		}; 
    		s++; 
    		if(s%29==0) {
    			s = 1;
    		};
    		m++;
    		if(m%20==0) {
    			m = 1;
    		}
    		year++;
    	}
    	System.out.println(year);
    }
}