HDU1431+简单题

时间:2022-08-02 16:52:38

题意简单

预处理之后会发现符合条件的数最多781个。。。

所以打表。。

 /*

 */
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int inf = 0x3f3f3f3f;
const double pi=acos(-1.0);
const int dx[]={,-,,};
const int dy[]={,,,-};
const double eps = 1e-;
/*const int maxm = 5761460;
const int maxn = 100000005; bool isPrime[ maxn ];
int Prime[ maxm ];
int Perfect[ 800 ];
int cntPrime,cntPerfect; void initPrime(){
cntPrime = 0;
for( int i=0;i<maxn;i+=2 ){
isPrime[ i ] = false;
}
for( int i=1;i<maxn;i+=2 ){
isPrime[ i ] = true;
}
isPrime[ 1 ] = false;
isPrime[ 2 ] = true;
Prime[ cntPrime++ ] = 2;
for( int i=3;i<maxn;i+=2 ){
if( isPrime[ i ]==true ){
int delta = 2*i;
int t = delta + i;
while( t<maxn ){
isPrime[ t ] = false;
t += delta;
}
}
}
for( int i=3;i<maxn;i++ ){
if( isPrime[ i ]==true ){
Prime[ cntPrime++ ] = i;
}
}
//printf("cntPrime = %d\n",cntPrime);
} bool judgePerfect( int aim ){
int tmp[ 24 ];
int cnt = 0;
while( aim ){
tmp[ cnt++ ] = aim%10;
aim /= 10;
}
int L = 0;
int R = cnt-1;
while( L<=R ){
if( tmp[L]!=tmp[R] ) return false;
L++;
R--;
}
return true;
} void initPerfect(){
cntPerfect = 0;
for( int i=0;i<cntPrime;i++ ){
if( judgePerfect( Prime[ i ] )==true ){
printf("Perfect[ %d ] = %d;\n",cntPerfect,Prime[ i ]);
Perfect[ cntPerfect ++ ] = Prime[ i ];
}
}
printf("cntPerfect = %d\n",cntPerfect);
}
*/ int Perfect[ ]; void init(){
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
Perfect[ ] = ;
} int main(){
//freopen("out.txt","w",stdout);
//initPrime();
//initPerfect();
int L,R;
init();
int cntPerfect = ;
while( scanf("%d%d",&L,&R)== ){
if( L>R ) swap( L,R );
for( int i=;i<cntPerfect;i++ ){
if( Perfect[ i ]>=L && Perfect[ i ]<=R ){
printf("%d\n",Perfect[ i ]);
}
else if( Perfect[ i ]>R ) break;
}
printf("\n");
}
return ;
}