#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 10005 ;
int v[ maxn] , primes[ 1000005 ] , _isprime[ 1000005 ] ;
int psz = 0 ;
void precalc( )
{
for ( int i = 0 ; i < 1000005 ; ++ i)
_isprime[ i] = 1 ;
for ( int i = 2 ; i < 1000005 ; ++ i)
{
if ( _isprime[ i] )
{
primes[ psz++ ] = i;
for ( int j = i << 1 ; j < 1000005 ; j + = i)
_isprime[ j] = 0 ;
}
}
}
inline bool isprime( int x)
{
if ( x < 2 )
return false ;
if ( x < 1000000 ) return _isprime[ x] ;
for ( int i = 0 ; primes[ i] * primes[ i] <= x && i < psz; ++ i)
{
if ( x % primes[ i] == 0 )
return false ;
}
return true ;
}
void solve( )
{
int n;
scanf ( "%d" , & n) ;
for ( int i = 0 ; i < n; ++ i)
scanf ( "%d" , & v[ i] ) ;
int ans = - 1 , ansl = - 1 , ansr = - 1 ;
for ( int len = 2 ; len <= n && ans == - 1 ; ++ len)
{
int sum = 0 ;
for ( int i = 0 ; i < len; ++ i)
sum + = v[ i] ;
if ( isprime( sum) )
{
ans = len;
ansl = 0 ;
break ;
}
for ( int i = 0 ; i + len < n; ++ i)
{
sum - = v[ i] ;
sum + = v[ i+ len] ;
if ( isprime( sum) )
{
ans = len;
ansl = i+ 1 ;
break ;
}
}
}
if ( ans == - 1 )
printf ( "No prime subsequences.\n " ) ;
else
{
printf ( "Shortest prime subsequence length is %d: " , ans) ;
for ( int i = 0 ; i < ans; ++ i)
printf ( "%d " , v[ ansl+ i] ) ;
printf ( "\n " ) ;
}
}
int main( )
{
#ifdef _DEBUG
freopen ( "input.txt" , "r" , stdin ) ;
freopen ( "output.txt" , "w" , stdout ) ;
#endif
precalc( ) ;
int t;
scanf ( "%d" , & t) ;
while ( t-- )
solve( ) ;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IG1heG4gPS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CWJyZWFrOwoJCX0KCQlmb3IgKGludCBpID0gMDsgaSArIGxlbiA8IG47ICsraSkKCQl7CgkJCXN1bSAtPSB2W2ldOwoJCQlzdW0gKz0gdltpK2xlbl07CgkJCWlmIChpc3ByaW1lKHN1bSkpCgkJCXsKCQkJCWFucyA9IGxlbjsKCQkJCWFuc2wgPSBpKzE7CgkJCQlicmVhazsKCQkJfQoJCX0KCX0KCWlmIChhbnMgPT0gLTEpCgkJcHJpbnRmKCJObyBwcmltZSBzdWJzZXF1ZW5jZXMuXG4iKTsKCWVsc2UKCXsKCQlwcmludGYoIlNob3J0ZXN0IHByaW1lIHN1YnNlcXVlbmNlIGxlbmd0aCBpcyAlZDogIiwgYW5zKTsKCQlmb3IgKGludCBpID0gMDsgaSA8IGFuczsgKytpKQoJCQlwcmludGYoIiVkICIsIHZbYW5zbCtpXSk7CgkJcHJpbnRmKCJcbiIpOwoJfQp9CgppbnQgbWFpbigpCnsKI2lmZGVmIF9ERUJVRwoJZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CglmcmVvcGVuKCJvdXRwdXQudHh0IiwgInciLCBzdGRvdXQpOwojZW5kaWYKCglwcmVjYWxjKCk7CgoJaW50IHQ7CglzY2FuZigiJWQiLCAmdCk7Cgl3aGlsZSAodC0tKQoJCXNvbHZlKCk7CgoJcmV0dXJuIDA7Cn0=
compilation info
prog.cpp: In function ‘void solve()’:
prog.cpp:46: warning: unused variable ‘ansr’
prog.cpp:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
prog.cpp: In function ‘int main()’:
prog.cpp:91: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout