Cod sursa(job #1154668)
| Utilizator | Data | 26 martie 2014 12:07:15 | |
|---|---|---|---|
| Problema | Cel mai lung subsir comun | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include<cstdio>
#include<cmath>
using namespace std;
long long t,n,nrot,rez;
double nfix;
int main()
{
freopen("chiftea.in","r",stdin);
freopen("chiftea.out","w",stdout);
scanf("%ld",&t);
while(t--)
{
scanf("%ld",&n);
nfix=sqrt(n);
nrot=(int)nfix;
if(n==1) rez=4;
else if(nrot==nfix) rez=4*(nrot+1)-4;
else if(nrot+0.5>nfix) rez=4*(nrot+1)-2;
else rez=4*(nrot+1);
printf("%ld\n",rez);
}
return 0;
}
