10161

一道小水题,推一下规律即可

//============================================================================
// Name        : 10161.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int t, t1;

double n;

int main() {
	//freopen("a.txt", "r", stdin);
	while(scanf("%lf", &n)&&(fabs(n) > 1e-10))
	{
		t = (int)sqrt(n);
		if((int)(n) == t*t)
		{
			if(t%2)
			{
				printf("1 %d\n", t);
				continue;
			}
			else
			{
				printf("%d 1\n", t);
				continue;
			}
		}
		else
		{
			t1 = (int)(n) - t*t;
			if(t%2)
			{
				if(t1 >=1&&t1 <= t+1)
				{
					printf("%d %d\n", t1, t+1);
				}
				else
				{
					printf("%d %d\n", t+1, (t+1)*(t+1)+1-(int)(n));
				}
			}
			else
			{
				if(t1 >=1&&t1 <= t+1)
				{
					printf("%d %d\n", t+1, t1);
				}
				else
				{
					printf("%d %d\n", (t+1)*(t+1)+1-(int)(n), t+1);
				}

			}
		}
	}
	return 0;
}

posted @ 2011-05-16 22:13  KOKO's  阅读(159)  评论(0编辑  收藏  举报