minimum-class

See Russian Translation

After a long term relationship, Anandi and Jagdish decided to marry. Anandi being a studious girl decided to complete her studies first. What next, she comes to ABC Public School. Her classes haven't even started yet and Jagdish becomes restless, comes to her college and asks her to complete her studies as soon as possible. Here comes the twist.

Anandi has to attend N classes in total. On the first day, she couldn't attend more than one class as she was too exhausted from the Semester Registration process. If Anandi takes x classes on some day, then she can take x, x-1 or x+1 classes on the next day. Jagdish on the other hand has asked Anandi to take no more than one class on the final day of her course so that she wouldn't be too tired for the marriage ceremony.

Help Anandi calculate the minimum number of days required to complete her course, keeping in mind the conditions mentioned above.

Input :

The first line contains an integer T denoting the number of test cases.

Each of the next T lines contain an integer N.

Output :

T lines :  Minimum number of days required for each test case. 

Constraints

1 ≤ N ≤ 10^9

1 ≤ T ≤ 1000

SAMPLE INPUT
3
4
1
9 

SAMPLE OUTPUT
3
1
5 

Explanation

Case 1 :  1 + 2 + 1

Case 2 : 1

Case 3 : 1 + 2 + 3 + 2 + 1

Difficulty: EASY
Tags: Mathematics

Ad-hoc

Starter code:

Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math

a = []
testcase_num = eval(input())
for x in range(0, testcase_num):
	tot_classes = eval(input())
	tmp = 0
	tmp = round(math.sqrt(tot_classes))
	class_hr_possible = ((tmp * (tmp+1))/2) + (((tmp-1) * tmp)/2)
	tmp += (tmp-1)
	if (tot_classes <= class_hr_possible):
		a.append(tmp)
	else:
		tmp += 1
		a.append(tmp)
for p in a:
	print(int(p))


import sys
def is_int(token):
	try:
		int(token)
	except ValueError:
		return False
	else:
		 return True
def dayer(token):
	day_counter=0
	summer=1
	while (token>0):
#               print "\n token :%d \tsummer:%d \tday_counter:%d" %(token,summer,day_counter)
		token-=summer
		if(token>0):
			day_counter+=2
			token-=summer
#                       print "After if \ntoken :%d \tsummer:%d \tday_counter:%d" %(token,summer,day_counter)
		else:
			day_counter+=1
		summer+=1
	return day_counter
tc=input()
n=[]
#flag =True
if(is_int(tc)):
	for i in range(0,int(tc)):
		tmp=input()
		if(is_int(tmp)):
			n.append(int(tmp));
		else:
			exit(0)

#tc=3
#n=[4,1,9]
#print n
for i in n:
	print(dayer(i))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
from math import sqrt
t=eval(input())
while t>0:
	t-=1
	n=eval(input())
	if n in [0,1,2]:
		print(n)
	else:
		k=int(sqrt(n))
		if k*k==n:
			print(2*k-1)
		else:
			a=2*k
			if n<=k*k+k:
				print(a)
			else:
				print(a+1)


a = input('')
a = int(a)
l = []
for cnt in range(a):
	b = input('')
	b = int(b)
	c = b**0.5
	c = int(c)
	d = c**2
	if d == b:
		l.append(2*c-1)
	elif b<=d+c:
		l.append(2*c)
	else:
		l.append(2*c+1)
for cnt in l:
	print(cnt)
		


t=int(eval(input()))
for z in range(t):
	n=eval(input())
	c=int(n**0.5)
	if n==c**2:
		print(2*c-1)
	elif n<=c**2+c: print(2*c)
	else :print(2*c+1)
	
	


import math
for _ in range(int(input())):
	x=int(input())
	y=math.sqrt(x)-1
	if int(y)==y:
		print((int(2*y)+1))
	else:
		print((int(2*y)+2))


import sys
def is_int(token):
	try:
		int(token)
	except ValueError:
		return False
	else:
		 return True
def dayer(token):
	day_counter=0
	summer=1
	while (token>0):
#               print "\n token :%d \tsummer:%d \tday_counter:%d" %(token,summer,day_counter)
		token-=summer
		if(token>0):
			day_counter+=2
			token-=summer
#                       print "After if \ntoken :%d \tsummer:%d \tday_counter:%d" %(token,summer,day_counter)
		else:
			day_counter+=1
		summer+=1
	return day_counter
tc=input()
n=[]
#flag =True
if(is_int(tc)):
	for i in range(0,int(tc)):
		tmp=input()
		if(is_int(tmp)):
			n.append(int(tmp));
		else:
			exit(0)

#tc=3
#n=[4,1,9]
#print n
for i in n:
	print(dayer(i))


import math

N = int(input())

def ap(n):
	return n*(n+1)

def get_possible(n):
	s = int(math.sqrt(n))
	d = ap(s) - n
	return s*2-1 if s**2==n else s*2 if d>=0 else s*2+1
	
for i in range(N):
	print(get_possible(int(input())))


t=int(eval(input()))
for z in range(t):
	n=eval(input())
	c=int(n**0.5)
	if n==c**2:
		print(2*c-1)
	elif n<=c**2+c: print(2*c)
	else :print(2*c+1)
	
	


from math import sqrt
for _ in range(int(input())):
	n = int(input())
	sqrtn = int(sqrt(n))
	
	if(n > sqrtn**2 and n<=(sqrtn**2 + sqrtn)):
		print(2*sqrtn)
	elif(n==sqrtn**2):
		print((2*sqrtn - 1))
	else:
		print((2*(sqrtn+1) - 1))


a = input('')
a = int(a)
l = []
for count in range(a):
	b = input('')
	b = int(b)
	c = b**0.5
	c = int(c)
	d = c**2
	if b == d:
		l.append((2*c -1))
	elif b <= d + c:
		l.append((2*c))
	else:
		l.append((2*c)+1)
	
for count1 in range(a):
	print((str(l[count1])))


import math

for i in range(int(input())):

	a=[1]
	classes = int(input())

	n= math.trunc(math.sqrt(classes))
	
	if (n*n) == classes:
		print(2*n-1)
	elif (n*n)+n < classes:
		print(2*n+1)
	else:
				print(2*n)



from math import sqrt,ceil

def cal(n):
	n=sqrt(n)
	n=n*2-1
	n=int(ceil(n))
	print(n)
tc = int(input())
while tc>0:
	n=int(input())
	cal(n)
	tc -=1


import math
t=eval(input())
for _ in range(t):
	n=eval(input())
	x=int(math.sqrt(n))
	if n==x**2:
		print(x*2-1)
		continue
	if n>(x**2)+x :
		x+=1
		print(2*x-1)
		continue
	print(2*x)


t=int(input())
while t>0:
	n=int(input())
	x=1
	c=1
	d=1
	r=1
	x=(pow((4*n)+1,.5)-1)/2
	if x%1==0:
		print(2*int(x))
	else:
		if n>pow(int(x)+1,2):
			print(2*(int(x))+2)
		else:	
		  print((2*int(x))+1)
	t=t-1