Inor

[백준] 10250번 ACM 호텔 본문

Algorithm/백준

[백준] 10250번 ACM 호텔

Inor 2017. 12. 10. 14:44

- 문제 : https://www.acmicpc.net/problem/10250


 문제가 길지만 간단한 문제입니다. 사람의 번호를 층수로 나누었고 엘리베이터에서 얼만큼 떨어져있는지를 계산했습니다. 그리고 나머지 연산으로 사람 번호를 층으로 계산했습니다. 몇 층에 있는지 계산하기 위함이었고 0이 나오면 가장 위의 층에 있는 경우이므로 따로 분기해서 계산 했습니다.


- 소스 코드


import java.util.Scanner;

public class ACMHotel {
	int tNum;
	int[][] testCases;
	int[] results;
	
	public void solve() {
		Scanner sc = new Scanner(System.in);
		String tString;
		
		tNum = sc.nextInt();
		testCases = new int[tNum][3];
		results = new int[tNum];
		
		for(int i=0;i<tNum;i++){
			for(int j=0;j<3;j++){
				testCases[i][j] = sc.nextInt();
			}
		}
		
		int h,w;
		for(int i=0;i<tNum;i++){
			h = testCases[i][2]%testCases[i][0];
			w = testCases[i][2]/testCases[i][0];
			if(h == 0){
				h = testCases[i][0];
				results[i] = h*100 + w;
			}else {
				results[i] = h*100 + w + 1;
			}
			
			System.out.println(results[i]);
		}
		
	}

	public static void main(String[] args) {
		ACMHotel m = new ACMHotel();
		m.solve();
	}

}


'Algorithm > 백준' 카테고리의 다른 글

[백준] 9324번 진짜 메시지  (0) 2017.12.20
[백준] 2851번 슈퍼 마리오  (0) 2017.12.18
[백준] 11015번 붕어빵 판매하기  (0) 2017.11.27
[백준] 14888번 연산자 끼워넣기  (0) 2017.11.20
[백준] 14891번 톱니바퀴  (0) 2017.11.13
Comments