10250 ACM 호텔

2019. 10. 3. 01:20알고리즘/백준

손님 번호 % 층 개수 == 0일때만 예외처리를 하면 쉽게 방번호를 구할 수 있다

 

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

깃허브주소: https://github.com/surinoel/boj/blob/master/10250.cpp

 

#include <iostream>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tc;
cin >> tc;
while (tc--) {
int n, m, k;
cin >> n >> m >> k;
int a = k / n;
if (k % n == 0) {
cout << (n * 100) + (k / n) << '\n';
}
else {
a += 1;
int b = k % n;
cout << (b * 100) + a << '\n';
}
}
return 0;
}
view raw 10250.cpp hosted with ❤ by GitHub

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

2790 F7  (0) 2019.10.06
프로그래머스 모의고사  (0) 2019.10.04
16935 배열 돌리기 3  (0) 2019.10.02
16937 두 스티커  (0) 2019.09.30
char 자료형을 to_string 주의할 점  (0) 2019.09.27