백준 10250번

김경욱·2026년 1월 24일

백준

목록 보기
109/121

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

// Press Shift twice to open the Search Everywhere dialog and type show whitespaces,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int a = Integer.parseInt(br.readLine());

    for (int i = 0; i < a; i++) {
        StringTokenizer st = new StringTokenizer(br.readLine());
        int H = Integer.parseInt(st.nextToken());
        int W = Integer.parseInt(st.nextToken());
        int guest = Integer.parseInt(st.nextToken());

        int room = 0;
        room = guest % H;
        if(room ==0 )
        {
            room = H;
        }
        int floor =0;



        floor =  guest / H + 1; // 10 10 10 -> 1001호 꼭대기 층일 때 문제 발생
        // 10 10 12
        if ( guest % H ==0) {
            floor = guest / H;
        }




        int answer = room * 100 + floor;

        System.out.println(answer);


    }




}

}

생각보다 어려웠던 브론즈3 문제...
꼭대기층이 예외 상황이므로 그것을 인지해야했고.!
처음에 출력할때는 String.valueOf(room)+"0"+String.valueOf(floor)를 사용하여 문자로 출력하려 했지만, 호수가 10호수를 넘어가면 그때부터 답이 틀리게 나오므로 결론적으로, room*100+floor을 써야했다.

0개의 댓글