백준 2525번 오븐시게(java)

마뇽미뇽·2024년 4월 28일
0

알고리즘 문제풀이

목록 보기
19/165

1.문제

https://www.acmicpc.net/problem/2525

2.풀이

60분 = 1시간이기 때문에 시간은 몫으로 분은 나머지로 구한다.

3.코드

import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int h = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
    
        sc.close();

        int M = (m + c)%60;
        int H = h + (m+c)/60;
        
        if(H > 23)  System.out.println(H - 24 + " " + M);
        else System.out.println(H + " " + M);

    }
}
profile
Que sera, sera

0개의 댓글