정수 N이 입력되면 00시 00분 00초부터 N시 59분 59초까지의 모든 시각 중에서 3이 하나라도 포함되는 모든 경우의 수를 구하는 프로그램을 작성하시오. 예를 들어 1을 입력했을 때 다음은 3이 하나라도 포함되어 있으므로 세어야 하는 시각이다.
반면에 다음은 3이 하나도 포함되어 있지 않으므로 세면 안 되는 시각이다.
(입력 조건)
(출력조건)
입력 예시
5
출력 예시
11475
시각을 흐르게 만든다. (시, 분, 초로 나누어 흐르게 한다.)
시각에 3이 하나라도 존재할 때 마다 답을 1개씩 추가한다.
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int answer = 0;
for (int hour = 0; hour <= N; hour++) {
for (int min = 0; min <= 59; min++) {
for (int sec = 0; sec <= 59; sec++) {
if (hour % 10 == 3 || min / 10 == 3 || min % 10 == 3 || sec / 10 ==3 || sec % 10 ==3) answer++;
}
}
}
System.out.println(answer);
}
}
I'm feeling a bit apprehensive about this Buckshot Roulette section on time manipulation in Java. It seems like it might involve some tricky logic and calculations.
Just went through your post on counting instances where the number 3 appears in the time from 00:00:00 to N:59:59 using Java. The approach of using nested loops to check every hour, minute, and second for the presence of a '3' is a clever way to tackle this problem. It's a neat example of how straightforward logic can solve what seems like a complex issue at first glance. Y9 Really enjoyed how you laid out the solution and the code snippet provided. Great job on breaking down the problem and offering a clear solution!
오! Java로 시간에서 3이 들어간 횟수 세는 문제라니, 신박하네요! 코딩 테스트에 나올 법한 스타일인데, 꼼꼼하게 풀어놓으신 것 같아요. 저도 한번 풀어봐야겠어요! @chill guy clicker
코딩에 대한 열정이 느껴져서 좋네요! Java 시간 계산 알고리즘은 정말 실무에서 자주 쓰이죠.
특히 날짜/시간 처리할 때는 LocalDateTime과 Duration 클래스 조합이 효과적이고, 시간대 처리가 필요하면 ZonedDateTime도 고려해보세요. 또한 성능이 중요한 상황에서는 Instant 클래스로 나노초 단위 계산도 가능합니다. 이런 기술적 역량을 개발자 취업에 활용하려면 AI Cover Letter Generator로 본인의 코딩 스킬과 프로젝트 경험을 효과적으로 어필할 수 있어요. 실제 프로젝트에서 이런 기법들을 적용해보시면 더욱 탄탄한 코드를 작성할 수 있을 거예요!
완전 탐색 문제 풀이 깔끔하네요! 시간 내 '3' 포함 여부 찾는 아이디어가 신선해요. 혹시 AI Video Generator 활용해서 코딩 과정을 시각적으로 설명하는 영상 만들어봐도 재밌을 것 같아요!
This subway surfers program prompts the user to enter the value of N and calculates the number of times from 00:00:00 to N:59:59 that contain at least one digit 3. It uses nested loops to iterate through the time components and checks if any of them contain the digit 3. The count is incremented whenever a match is found. Finally, the program outputs the result.