본문 바로가기
IT/알고리즘

백준 10250 ACM호텔

by 어센트 2020. 1. 10.

 

간단한 문제였다. 층수를 정할때 나머지가 0일때 예외처리만 해주면 간단하게 풀 수 있었다.

 

풀이

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
import java.util.Scanner;
 
public class ACM호텔 {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int  T = sc.nextInt();
        int res = 0;
        for(int i=0;i<T;i++) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            int n = sc.nextInt();
 
            int rNum = n/h; //방번호 끝자리 rNum
            if(n%h!=0) rNum++;
            
            int fNum = n%h; //층번호
            if (fNum == 0)fNum = h;
 
            res = 100*fNum+rNum;
            System.out.println(res);
 
        }
 
    }
 
}
cs