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);
}
}