Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

AndOnAChessBoard/허준수

From ZeroWiki
Revision as of 05:22, 7 February 2021 by imported>Unknown
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

소감

간단하게 돌아가게 해보려고 했다. 레베루가 1인 만큼 그다지 어렵지는 않은 듯. 아직 로봇에 돌려보지는 않았다. -..ㅡ;;


코드

#include <iostream>
#include <cmath>
using namespace std;

int findLine(int input)
{
	double num = ceil((double)sqrt(input))	;
	return (int)num;
}

void process(int input)
{
	int line = findLine(input);
	int num = line*line;

	for( int i = 1; i<=(2*line); i++) {
		if(input == num - i + 1) break;
	}
	
	if(i >= line) 
		cout << line << " " << 2*line - i <<endl;
	else 
		cout << i << " " << line <<endl;
}

int main()
{
	int input;
	while(cin >> input) {
		if(input == 0) break;
			process(input);
	}

	return 0;
}