-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
57 lines (51 loc) · 1.45 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package backjoon.date_calculate_1476;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
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 earth = Integer.parseInt(st.nextToken());
int sun = Integer.parseInt(st.nextToken());
int moon = Integer.parseInt(st.nextToken());
int year = 1;
int e = 1;
int s = 1;
int m = 1;
while (true) {
if (earth == e && sun == s && moon == m) {
break;
}
year++;
e++;
s++;
m++;
if (e > 15) {
e = 1;
}
if (s > 28) {
s = 1;
}
if (m > 19) {
m = 1;
}
}
System.out.println(year);
}
/**
*
* 구글에서 본 최소공배수를 이용한 아름다운 풀이법
*/
protected static void solution(int earth, int sun, int moon) {
int year = 0;
while (true) {
year++;
if ((year - earth) % 15 == 0 && (year - sun) % 28 == 0 && (year - moon) % 19 == 0) {
break;
}
}
System.out.print(year);
}
}