본문 바로가기

기록/알고리즘

백준 10250번) ACM 호텔

SMALL

 

import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) throws IOException {
		Scanner scan = new Scanner(System.in);
		
		int testcase = scan.nextInt();
		int[][] result = new int[testcase][3];
		for(int i = 0; i < testcase; i++) {
			result[i][0] = scan.nextInt();
			result[i][1] = scan.nextInt();
			result[i][2] = scan.nextInt();
		}
		
		for(int i = 0; i < testcase; i++) {
			System.out.println(room(result[i][0], result[i][1], result[i][2]));
		}
	}
	public static int room(int H, int W, int n) {
		int w = (n / H) + 1;
		int h = (n % H);
		
	
		if(n % H == 0) {
			w--;
			h = H;
		}
		return h * 100 + w;
	}
}

방의 위치는 호수에 대해서 결정된다.

단, 나누어 떨어질 때는 최상층임을 감안하여 해당하는 조건식을 부여한다.

SMALL