알고리즘

C++ 알고리즘 - 백준 10250 ACM 호텔

마루설아 2024. 12. 14. 18:15
#include <iostream>
#include <string>
using namespace std;

int main(void) {
	// C++ Init
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int input;
	cin >> input;

	int height, width, man;
	int pos1, pos2;
	string room;

	for (int i = 0; i < input; i++) {
		cin >> height >> width >> man;
		pos1 = 1;
		pos2 = 1;

		for (int j = 1; j < man; j++) {
			if (pos1 + 1 > height) {
				pos2++;
				pos1 = 1;
			}

			else pos1++;

		}

		if (to_string(pos2).length() == 1)
			room = to_string(pos1) + "0" + to_string(pos2);
		else
			room = to_string(pos1) + to_string(pos2);

		cout << room << "\n";
	}
}