U E D R , A S I H C RSS

Steps/하기웅

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

int testcase, x, y, sqrtNum, powNum;

int showResult(int number)
{
	sqrtNum = floor(sqrt(number-1));
	powNum = sqrtNum * sqrtNum;
	if(number==0)
		return 0;
	else if(number>powNum && number<=(powNum+sqrtNum))
		return 2*sqrtNum;
	else
		return 2*sqrtNum+1;
}

int main()
{
	cin >> testcase;
	while(testcase--)
	{
		cin>>x>>y;
		cout << showResult(y-x) << endl;
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:07
Processing time 0.0129 sec