[백준] 10250 - ACM Hotel



문제 정보


  • 문제 이름: ACM Hotel (원문)
  • 문제 번호: 10250
  • 문제 유형: -
  • 풀이 언어: C
  • 제출 시간: 2019년 5월 12일 17시 2분 12초
  • 원본 링크: https://www.acmicpc.net/problem/10250



문제

Jiwoo, the manager of the ACM Hotel, is about to assign the vacant rooms to the guests upon their arrival. According to customers’ survey, the customers prefer the rooms which are close to the main entrance on-walk. Jiwoo likes to assign the rooms on this policy. Write a program to help Jiwoo on assigning the rooms for the guests.

For simplicity, let’s assume that the ACM hotel is a rectangular shape, an H story building with W rooms on each floor (1 ≤ H, W ≤ 99) and that the only one elevator is on the leftmost side (see Figure 1). Let’s call this kind of hotel as H × W shaped. The main entrance is located on the first floor near the elevator. You may ignore the distance between the gate and the elevator. Also assume that the distances between neighboring rooms are all the same, the unit distance, and that all the rooms only in the front side of the hotel.

The rooms are numbered in YXX or YYXX style where Y or YY denotes the number of the floor and XX, the index of the room counted from the left. Therefore the room shaded in Figure 1 should be 305.

The customers do not concern the distance moved in the elevator though the room on the lower floor is preferred than that on the higher floor if the walking distance is same. For instance, the room 301 is preferred than the room 102 since the customer should walk for two units for the latter but one unit, for the former. Additionally, the room 2101 is preferred than the room 102.

Your program should compute the room number which should be assigned for the N-th guest according to this policy assuming that all the rooms are vacant initially. The first guest should be assigned to 101, the second guest to 201, and so on. In Figure 1, for example, the 10th guest should be assigned to the room 402 since H = 6.



입력

Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case consists of a single line containing and integers H, W, and N: the number of floors, the number of rooms on each floor, and the index of the arrival time of the guest to be assigned a room, respectively, where 1 ≤ H, W ≤ 99 and 1 ≤ N ≤ H × W.



출력

Your program is to write to standard output. Print exactly one line for each test case. The line should contain the room number of the given hotel, where the N-th guest should be assigned.



결과 - 소스코드 및 랭크






메모

초기에 3개의 for문을 그대로 적용했는데 중간에 break문을 이용해 최상위 for문으로 탈출하는 것이 애매했다.

처음에는 goto문도 생각해보고, 관련된 내용을 찾아보니 flag나 labeling을 통해 특정 for문을 탈출할 수 있다고 하는데 실무적으로는 이러한 기능보다 함수를 이용한 return 방식을 조금 더 선호한다고 해서 함수를 추가하여 return으로 값을 내도록 했다.

이번에 랭크를 보고 생각보다 내가 짠 줄이 너무 길구나 싶어서 봤는데 가독성을 고려하지 않고 압축해서 문제를 푸신 분들이 너무 많이 계시고 메모리도 백준 온라인 컴파일러에 의해 어느 정도 변동될 수 있는 것으로 보아 랭크 정보는 업로드해도 크게 생각하지 않고 문제를 풀었다는 점에만 집중할 수 있도록 해야겠다. 물론 내가 푼 방식도 더 줄일 수 있게 바꾸긴 해야 한다. ㅠㅠ

그래도 예전에 못 풀었던 문제들을 하나둘씩 풀어가는 것만으로도 행복하다. ㅎㅎ

Author

Alec J

Posted on

2019-05-12

Updated on

2021-02-09

Licensed under