规律题每增加4条边有个规律,注意用Long long
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
long long ans,i;
scanf("%d",&n);
if(n<=2){printf("4\n");continue;}
for( i=4;i<=100000;i+=4)
{
ans=i*i/8;
if(ans>=n)break;
}
// printf("%d\n",i);
if(ans==n)printf("%d\n",i);
else
{
i-=4;
ans=i*i/8;
int bian1=i/4-1;
int bian2=i/2;
int bian3=bian2+bian1+1;
// cout<<ans+bian1<<" "<<ans+bian2<<" "<<ans+bian3<<" "<<endl;
if(ans+bian1>=n)printf("%d\n",i+1);
else if(ans+bian2>=n)printf("%d\n",i+2);
else if(ans+bian3>=n)printf("%d\n",i+3);
else printf("%d\n",i+4);
}
}
return 0;
}