Skip to content

Commit 2ee1999

Browse files
authored
Merge pull request #1565 from AlgorithmWithGod/zinnnn37
[20251202] PGM / LV2 / 아날로그 시계 / 김민진
2 parents 8b89058 + 1fec138 commit 2ee1999

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
```java
2+
import java.util.*;
3+
4+
public class PGM_Lv2_아날로그_시계 {
5+
6+
private static final double secMin = 3600.0 / 59;
7+
private static final double secHour = 43200.0 / 719;
8+
9+
private static int ans;
10+
private static double time;
11+
private static Set<Double> set = new HashSet<>();
12+
13+
public int solution(int h1, int m1, int s1, int h2, int m2, int s2) {
14+
ans = 0;
15+
16+
int sec1 = h1 * 60 * 60 + m1 * 60 + s1;
17+
int sec2 = h2 * 60 * 60 + m2 * 60 + s2;
18+
19+
for (int i = 0; i * secMin <= sec2; i++) {
20+
time = i * secMin;
21+
if (sec1 <= time) {
22+
set.add(time);
23+
}
24+
}
25+
26+
for (int i = 0; i * secHour <= sec2; i++) {
27+
time = i * secHour;
28+
if (sec1 <= time) {
29+
set.add(time);
30+
}
31+
}
32+
33+
System.out.println("\n" + set.size());
34+
35+
return set.size();
36+
}
37+
}
38+
```

0 commit comments

Comments
 (0)