1 ≤ E ≤ 15, 1 ≤ S ≤ 28, 1 ≤ M ≤ 19 를 충족하도록 식을 짜야한다.
import java.util.*;
public class Num1476 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int E = sc.nextInt();
int S = sc.nextInt();
int M = sc.nextInt();
int e =1, s=1, m=1;
for(int i=1; ; i++) {
if (e == E && s == S && m == M) {
System.out.println(i);
break;
}
e++;
s++;
m++;
if (e == 16) {
e = 1;
}
if (s == 29) {
s = 1;
}
if (m == 20) {
m = 1;
}
}
}
}
참고 :
출처 : https://www.acmicpc.net/problem/1476