/*===================
From : Zoj1239
Author : zscas08220
Algorithm : 模拟
===================*/
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std ;
int a [ 55 ];
void init ()
{
fill ( a , a + 55 , 0 );
a [ 1 ] = 1 ;
int p [ 2000 ], peg = 1 , cur = 2 ;
fill (p , p + 2000 , 0 );
p [ 1 ] = 1 ;
while ( true )
{
if ( peg > 50 ) break ;
bool flag = false ;
for ( int i = 1 ; i <= peg ; i ++ )
{
int tmp = sqrt (p [ i ] + cur );
if ( tmp * tmp == p [ i ] + cur )
{
flag = true ;
p [ i ] = cur ;
}
}
if ( ! flag )
{
a [ peg ] = cur - 1 ;
p [ peg + 1 ] = cur ;
peg ++ ;
}
cur ++ ;
}
}
int main ()
{
init ();
int t , n;
cin >> t ;
while ( t -- )
{
cin >> n;
cout << a [ n ] << endl ;
}
return 0 ;
}
From : Zoj1239
Author : zscas08220
Algorithm : 模拟
===================*/
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std ;
int a [ 55 ];
void init ()
{
fill ( a , a + 55 , 0 );
a [ 1 ] = 1 ;
int p [ 2000 ], peg = 1 , cur = 2 ;
fill (p , p + 2000 , 0 );
p [ 1 ] = 1 ;
while ( true )
{
if ( peg > 50 ) break ;
bool flag = false ;
for ( int i = 1 ; i <= peg ; i ++ )
{
int tmp = sqrt (p [ i ] + cur );
if ( tmp * tmp == p [ i ] + cur )
{
flag = true ;
p [ i ] = cur ;
}
}
if ( ! flag )
{
a [ peg ] = cur - 1 ;
p [ peg + 1 ] = cur ;
peg ++ ;
}
cur ++ ;
}
}
int main ()
{
init ();
int t , n;
cin >> t ;
while ( t -- )
{
cin >> n;
cout << a [ n ] << endl ;
}
return 0 ;
}