반응형

1. 문제 번호 2525번


 

2. 한 줄 키워드 

 - 입력값 시간,분을 합산한 분(=totalMinutes)으로 변경

 - totalMinutes >= 1440 일때는 %24로 만들어줌

 


나의 문제풀이 방식 및 순서

 - 앞선 2884번과 동일



3. 소스 인증

import java.util.*;
import java.lang.*;
import java.io.*;

/**********************

Writer : KTH
Purpose: 

**********************/

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine()," ");

        int I_hh = Integer.parseInt(st.nextToken()); //공백열 구분
        int I_mm = Integer.parseInt(st.nextToken());
        int targetWorkTime = Integer.parseInt(br.readLine()); //Enter 구분
        
        int totalMinutes = I_hh * 60 + I_mm;
        int targetMinutes = totalMinutes + targetWorkTime;

        if(targetMinutes>=1440){
            targetMinutes -= 24*60;
        }

        int resultHour = targetMinutes / 60 ;
        int resultMinutes = targetMinutes % 60;
        
        System.out.println(resultHour+" "+resultMinutes);

    }
}

4. 추가 개념

 

 

 

 

728x90
반응형

'알고리즘(BOJ) 문제풀이' 카테고리의 다른 글

[BOJ/백준] 조건문_2480번  (0) 2024.05.07
[BOJ/백준] 조건문_2884  (0) 2024.05.07
[BOJ/백준] 조건문_14681  (0) 2024.05.03
[BOJ/백준] 조건문_2753  (0) 2024.05.03
[BOJ/백준] 조건문_9498  (0) 2024.05.03

+ Recent posts