U E D R , A S I H C RSS

And OnAChess Board/허준수

. 1 .
. -..ㅡ;;

~cpp
#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;
}


Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:28
Processing time 0.0171 sec