취미처럼

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

Algorithm/백준

[백준] 1476번 날짜 계산

sirius 2021. 2. 25. 10:15
https://www.acmicpc.net/problem/1476
 

1476번: 날짜 계산

준규가 사는 나라는 우리가 사용하는 연도와 다른 방식을 이용한다. 준규가 사는 나라에서는 수 3개를 이용해서 연도를 나타낸다. 각각의 수는 지구, 태양, 그리고 달을 나타낸다. 지구를 나타

www.acmicpc.net

 

import java.util.*;


public class Main {

    public static void main(String[] args) throws Exception {

        int a = 1;
        int b = 1;
        int c = 1;

        int year = 1;

        Scanner sc = new Scanner(System.in);
        int e = sc.nextInt();
        int s = sc.nextInt();
        int m = sc.nextInt();

        while(true) {
            if(a == e && b == s && c == m ) {
           		break;
            }
            year++;
            a++;
            b++;
            c++;
            if(a == 16) {
            	a = 1;
            }
            if(b == 29) {
            	b = 1;
            }
            if(c == 20) {
            	c = 1;
            }

        }

        System.out.println(year);
    }
}

'Algorithm > 백준' 카테고리의 다른 글

[백준] 14500번 테트로미노  (0) 2021.03.02
[백준] 1107번 리모컨  (0) 2021.03.02
[백준] 3085번 사탕 게임  (0) 2021.02.25
[백준] 2309번 일곱 난쟁이  (0) 2021.02.25
[백준] 6588번 골드바흐의 추측  (0) 2021.02.25
Comments