1. 문제 링크
https://www.acmicpc.net/problem/10250
2. 문제 요약
- H x W의 크기를 가진 호텔에서 다음 손님이 들어갈 방을 배정(높이 x 너
- 손님들은 101호, 201호, ... W01호, 102호 ... 순으로 선호함
3. 문제 풀이
- 3 x 4의 호텔에서 5번째 들어갈 손님은
5%3 층
5/3 호 (반올림) 이 된다
4. 소스코드(c)
#include <stdio.h>
#include <math.h>
int main(void)
{
int i;
int caseCount;
int hotel[100][100] = {0, };
int heightCount, widthCount;
int width;
double customerIndex;
double height;
scanf("%d", &caseCount);
for (i = 0; i < caseCount; i++) {
scanf("%d %d %lf", &heightCount, &widthCount, &customerIndex);
height = (int)customerIndex%heightCount;
if (height == 0)
printf("%d", heightCount);
else
printf("%d", (int)height);
width = ceil(customerIndex/heightCount);
if (width < 10)
printf("0%d\n", width);
else
printf("%d\n", width);
}
return 0;
}
댓글 없음:
댓글 쓰기