http://acm.hdu.edu.cn/showproblem.php?pid=6154
队友写的,画了好久,很强势
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t,k;
scanf("%d",&t);
while(t--)
{
scanf("%d",&k);
int i=ceil(sqrt((double)k/2.0));
int bb[4];
bb[0]=4*i;
bb[1]=bb[0]-1;
bb[2]=bb[1]-1;
bb[3]=bb[2]-1;
/* for(int i=0;i<4;i++) cout<<bb[i]<<" "; cout<<endl;*/
double aa[4];
aa[0]=2*i*i;
aa[1]=aa[0]-(double)(i*2+1)/2.0;
aa[2]=aa[1]-(double)((i-1)*2+1)/2.0;
aa[3]=aa[2]-(double)((i-1)*2+1)/2.0;
/*for(int i=0;i<4;i++) cout<<aa[i]<<" "; cout<<endl;*/
int biao=0;
for(int i=0;i<4;i++)
{
if(aa[i]>=k)
biao=i;
}
// cout<<"biao:"<<biao<<endl;
printf("%d\n",bb[biao]);
}
return 0;
}