Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified kokeunho/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions kokeunho/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
| 29์ฐจ์‹œ | 2025.07.21 | ๊ทธ๋ž˜ํ”„ ํƒ์ƒ‰ | [๋ถˆ!](https://www.acmicpc.net/problem/4179) |[#118](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/118) |
| 30์ฐจ์‹œ | 2025.07.26 | ๊ทธ๋ž˜ํ”„ ํƒ์ƒ‰ | [์ค‘๋Ÿ‰์ œํ•œ](https://www.acmicpc.net/problem/1939) |[#120](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/120) |
| 31์ฐจ์‹œ | 2025.08.03 | ๊ทธ๋ž˜ํ”„ ํƒ์ƒ‰ | [๋ฉด์ ‘๋ณด๋Š” ์Šน๋ฒ”์ด๋„ค](https://www.acmicpc.net/problem/17835) | [#126](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/126) |
| 34์ฐจ์‹œ | 2025.08.30 | ๊ตฌํ˜„ | [์•„๋‚ ๋กœ๊ทธ ์‹œ๊ณ„](https://school.programmers.co.kr/learn/courses/30/lessons/250135) | [#137](https://github.com/AlgoLeadMe/AlgoLeadMe-12/pull/137) |
---
70 changes: 70 additions & 0 deletions kokeunho/๊ตฌํ˜„/34-kokeunho.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import java.util.*;

class Solution {
public int solution(int h1, int m1, int s1, int h2, int m2, int s2) {
int answer = 0;

int start = changeToSec(h1, m1, s1);
int end = changeToSec(h2, m2, s2);


for (int i = start; i < end; i++) {
List<Double> current = getDegree(i);
List<Double> next = getDegree(i+1);

boolean hMatch = hourMatch(current, next);
boolean mMatch = minMatch(current, next);

// ์ดˆ์นจ์ด ๋ถ„์นจ๊ณผ ์‹œ์นจ๊ณผ ๊ฒน์นจ์ด ๋ฐœ์ƒํ–ˆ์„ ๋•Œ,
if(hMatch && mMatch){
// ์‹œ์นจ๊ณผ ๋ถ„์นจ์˜ ๊ฐ๋„๊ฐ€ ๊ฐ™๋‹ค๋ฉด +1๋งŒ ํ•ด์ค˜์•ผํ•จ
if(Double.compare(next.get(0),next.get(1)) == 0) answer++;
// ์•„๋‹ˆ๋ผ๋ฉด +2
else answer +=2;
}
// ๋‘˜ ์ค‘ ํ•˜๋‚˜๋ผ๋„ ๊ฒน์น˜๋ฉด +1
else if(hMatch || mMatch) answer++;
}

if(start == 0 || start == 43200) answer++;

return answer;
}
public int changeToSec(int h, int m, int s) {
return 3600*h + 60*m + s;
}

public List<Double> getDegree(int t) {
int h = t/3600;
int m = (t%3600) / 60;
int s = (t%3600) % 60;

Double hDegree = (h%12) * 30 + m*0.5 + s*(1.0/120);
Double mDegree = m*6 + s*(0.1);
Double sDegree = s*6.0;

return List.of(hDegree, mDegree, sDegree);
}
public boolean hourMatch(List<Double> current, List<Double> next) {
if (Double.compare(current.get(0), current.get(2)) > 0
&& Double.compare(next.get(0), next.get(2)) <= 0) {
return true;
}
if (Double.compare(current.get(2), 354) == 0
&& Double.compare(current.get(0), 354) > 0) {
return true;
}
return false;
}
public boolean minMatch(List<Double> current, List<Double> next) {
if (Double.compare(current.get(1), current.get(2)) > 0
&& Double.compare(next.get(1), next.get(2)) <= 0) {
return true;
}
if (Double.compare(current.get(2), 354) == 0
&& Double.compare(current.get(1), 354) > 0) {
return true;
}
return false;
}
}