-
백준 2525 오븐 시계백준 (Java) 2022. 6. 10. 01:03
- 전체 시간 계산 후 시간 / 분 단위로 계산
- 24시 자정을 넘어가면 시를 0으로 세팅하여 계산
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int h = sc.nextInt(); int m = sc.nextInt(); int e = sc.nextInt(); // 시간 계산 int total = h*60 + m + e; h = total/60; m = total%60; // 24시간 계산 if(h>23) h=h-24; // 출력 System.out.println(h+" "+m); } }
https://www.acmicpc.net/problem/2525
2525번: 오븐 시계
첫째 줄에 종료되는 시각의 시와 분을 공백을 사이에 두고 출력한다. (단, 시는 0부터 23까지의 정수, 분은 0부터 59까지의 정수이다. 디지털 시계는 23시 59분에서 1분이 지나면 0시 0분이 된다.)
www.acmicpc.net
'백준 (Java)' 카테고리의 다른 글
백준 2480 주사위 세개 (0) 2022.06.10 백준 25083 새싹 (0) 2022.06.10 백준 10951 while문 이용하여 두 수의 합 구하기 (0) 2022.02.09 백준 10952 while문 사용하여 반복문 출력하기 (A+B - 5) (0) 2022.02.09 백준 10871 x보다 작은 수 (0) 2022.02.09