HDU1431+简单题
题意简单
预处理之后会发现符合条件的数最多781个。。。
所以打表。。
1 /* 2 3 */ 4 #include<algorithm> 5 #include<iostream> 6 #include<string.h> 7 #include<stdlib.h> 8 #include<stdio.h> 9 #include<math.h> 10 #include<queue> 11 #include<stack> 12 #include<map> 13 #include<set> 14 using namespace std; 15 typedef long long int64; 16 //typedef __int64 int64; 17 typedef pair<int64,int64> PII; 18 #define MP(a,b) make_pair((a),(b)) 19 const int inf = 0x3f3f3f3f; 20 const double pi=acos(-1.0); 21 const int dx[]={1,-1,0,0}; 22 const int dy[]={0,0,1,-1}; 23 const double eps = 1e-8; 24 /*const int maxm = 5761460; 25 const int maxn = 100000005; 26 27 bool isPrime[ maxn ]; 28 int Prime[ maxm ]; 29 int Perfect[ 800 ]; 30 int cntPrime,cntPerfect; 31 32 void initPrime(){ 33 cntPrime = 0; 34 for( int i=0;i<maxn;i+=2 ){ 35 isPrime[ i ] = false; 36 } 37 for( int i=1;i<maxn;i+=2 ){ 38 isPrime[ i ] = true; 39 } 40 isPrime[ 1 ] = false; 41 isPrime[ 2 ] = true; 42 Prime[ cntPrime++ ] = 2; 43 for( int i=3;i<maxn;i+=2 ){ 44 if( isPrime[ i ]==true ){ 45 int delta = 2*i; 46 int t = delta + i; 47 while( t<maxn ){ 48 isPrime[ t ] = false; 49 t += delta; 50 } 51 } 52 } 53 for( int i=3;i<maxn;i++ ){ 54 if( isPrime[ i ]==true ){ 55 Prime[ cntPrime++ ] = i; 56 } 57 } 58 //printf("cntPrime = %d\n",cntPrime); 59 } 60 61 bool judgePerfect( int aim ){ 62 int tmp[ 24 ]; 63 int cnt = 0; 64 while( aim ){ 65 tmp[ cnt++ ] = aim%10; 66 aim /= 10; 67 } 68 int L = 0; 69 int R = cnt-1; 70 while( L<=R ){ 71 if( tmp[L]!=tmp[R] ) return false; 72 L++; 73 R--; 74 } 75 return true; 76 } 77 78 void initPerfect(){ 79 cntPerfect = 0; 80 for( int i=0;i<cntPrime;i++ ){ 81 if( judgePerfect( Prime[ i ] )==true ){ 82 printf("Perfect[ %d ] = %d;\n",cntPerfect,Prime[ i ]); 83 Perfect[ cntPerfect ++ ] = Prime[ i ]; 84 } 85 } 86 printf("cntPerfect = %d\n",cntPerfect); 87 } 88 */ 89 90 int Perfect[ 800 ]; 91 92 void init(){ 93 Perfect[ 0 ] = 2; 94 Perfect[ 1 ] = 3; 95 Perfect[ 2 ] = 5; 96 Perfect[ 3 ] = 7; 97 Perfect[ 4 ] = 11; 98 Perfect[ 5 ] = 101; 99 Perfect[ 6 ] = 131; 100 Perfect[ 7 ] = 151; 101 Perfect[ 8 ] = 181; 102 Perfect[ 9 ] = 191; 103 Perfect[ 10 ] = 313; 104 Perfect[ 11 ] = 353; 105 Perfect[ 12 ] = 373; 106 Perfect[ 13 ] = 383; 107 Perfect[ 14 ] = 727; 108 Perfect[ 15 ] = 757; 109 Perfect[ 16 ] = 787; 110 Perfect[ 17 ] = 797; 111 Perfect[ 18 ] = 919; 112 Perfect[ 19 ] = 929; 113 Perfect[ 20 ] = 10301; 114 Perfect[ 21 ] = 10501; 115 Perfect[ 22 ] = 10601; 116 Perfect[ 23 ] = 11311; 117 Perfect[ 24 ] = 11411; 118 Perfect[ 25 ] = 12421; 119 Perfect[ 26 ] = 12721; 120 Perfect[ 27 ] = 12821; 121 Perfect[ 28 ] = 13331; 122 Perfect[ 29 ] = 13831; 123 Perfect[ 30 ] = 13931; 124 Perfect[ 31 ] = 14341; 125 Perfect[ 32 ] = 14741; 126 Perfect[ 33 ] = 15451; 127 Perfect[ 34 ] = 15551; 128 Perfect[ 35 ] = 16061; 129 Perfect[ 36 ] = 16361; 130 Perfect[ 37 ] = 16561; 131 Perfect[ 38 ] = 16661; 132 Perfect[ 39 ] = 17471; 133 Perfect[ 40 ] = 17971; 134 Perfect[ 41 ] = 18181; 135 Perfect[ 42 ] = 18481; 136 Perfect[ 43 ] = 19391; 137 Perfect[ 44 ] = 19891; 138 Perfect[ 45 ] = 19991; 139 Perfect[ 46 ] = 30103; 140 Perfect[ 47 ] = 30203; 141 Perfect[ 48 ] = 30403; 142 Perfect[ 49 ] = 30703; 143 Perfect[ 50 ] = 30803; 144 Perfect[ 51 ] = 31013; 145 Perfect[ 52 ] = 31513; 146 Perfect[ 53 ] = 32323; 147 Perfect[ 54 ] = 32423; 148 Perfect[ 55 ] = 33533; 149 Perfect[ 56 ] = 34543; 150 Perfect[ 57 ] = 34843; 151 Perfect[ 58 ] = 35053; 152 Perfect[ 59 ] = 35153; 153 Perfect[ 60 ] = 35353; 154 Perfect[ 61 ] = 35753; 155 Perfect[ 62 ] = 36263; 156 Perfect[ 63 ] = 36563; 157 Perfect[ 64 ] = 37273; 158 Perfect[ 65 ] = 37573; 159 Perfect[ 66 ] = 38083; 160 Perfect[ 67 ] = 38183; 161 Perfect[ 68 ] = 38783; 162 Perfect[ 69 ] = 39293; 163 Perfect[ 70 ] = 70207; 164 Perfect[ 71 ] = 70507; 165 Perfect[ 72 ] = 70607; 166 Perfect[ 73 ] = 71317; 167 Perfect[ 74 ] = 71917; 168 Perfect[ 75 ] = 72227; 169 Perfect[ 76 ] = 72727; 170 Perfect[ 77 ] = 73037; 171 Perfect[ 78 ] = 73237; 172 Perfect[ 79 ] = 73637; 173 Perfect[ 80 ] = 74047; 174 Perfect[ 81 ] = 74747; 175 Perfect[ 82 ] = 75557; 176 Perfect[ 83 ] = 76367; 177 Perfect[ 84 ] = 76667; 178 Perfect[ 85 ] = 77377; 179 Perfect[ 86 ] = 77477; 180 Perfect[ 87 ] = 77977; 181 Perfect[ 88 ] = 78487; 182 Perfect[ 89 ] = 78787; 183 Perfect[ 90 ] = 78887; 184 Perfect[ 91 ] = 79397; 185 Perfect[ 92 ] = 79697; 186 Perfect[ 93 ] = 79997; 187 Perfect[ 94 ] = 90709; 188 Perfect[ 95 ] = 91019; 189 Perfect[ 96 ] = 93139; 190 Perfect[ 97 ] = 93239; 191 Perfect[ 98 ] = 93739; 192 Perfect[ 99 ] = 94049; 193 Perfect[ 100 ] = 94349; 194 Perfect[ 101 ] = 94649; 195 Perfect[ 102 ] = 94849; 196 Perfect[ 103 ] = 94949; 197 Perfect[ 104 ] = 95959; 198 Perfect[ 105 ] = 96269; 199 Perfect[ 106 ] = 96469; 200 Perfect[ 107 ] = 96769; 201 Perfect[ 108 ] = 97379; 202 Perfect[ 109 ] = 97579; 203 Perfect[ 110 ] = 97879; 204 Perfect[ 111 ] = 98389; 205 Perfect[ 112 ] = 98689; 206 Perfect[ 113 ] = 1003001; 207 Perfect[ 114 ] = 1008001; 208 Perfect[ 115 ] = 1022201; 209 Perfect[ 116 ] = 1028201; 210 Perfect[ 117 ] = 1035301; 211 Perfect[ 118 ] = 1043401; 212 Perfect[ 119 ] = 1055501; 213 Perfect[ 120 ] = 1062601; 214 Perfect[ 121 ] = 1065601; 215 Perfect[ 122 ] = 1074701; 216 Perfect[ 123 ] = 1082801; 217 Perfect[ 124 ] = 1085801; 218 Perfect[ 125 ] = 1092901; 219 Perfect[ 126 ] = 1093901; 220 Perfect[ 127 ] = 1114111; 221 Perfect[ 128 ] = 1117111; 222 Perfect[ 129 ] = 1120211; 223 Perfect[ 130 ] = 1123211; 224 Perfect[ 131 ] = 1126211; 225 Perfect[ 132 ] = 1129211; 226 Perfect[ 133 ] = 1134311; 227 Perfect[ 134 ] = 1145411; 228 Perfect[ 135 ] = 1150511; 229 Perfect[ 136 ] = 1153511; 230 Perfect[ 137 ] = 1160611; 231 Perfect[ 138 ] = 1163611; 232 Perfect[ 139 ] = 1175711; 233 Perfect[ 140 ] = 1177711; 234 Perfect[ 141 ] = 1178711; 235 Perfect[ 142 ] = 1180811; 236 Perfect[ 143 ] = 1183811; 237 Perfect[ 144 ] = 1186811; 238 Perfect[ 145 ] = 1190911; 239 Perfect[ 146 ] = 1193911; 240 Perfect[ 147 ] = 1196911; 241 Perfect[ 148 ] = 1201021; 242 Perfect[ 149 ] = 1208021; 243 Perfect[ 150 ] = 1212121; 244 Perfect[ 151 ] = 1215121; 245 Perfect[ 152 ] = 1218121; 246 Perfect[ 153 ] = 1221221; 247 Perfect[ 154 ] = 1235321; 248 Perfect[ 155 ] = 1242421; 249 Perfect[ 156 ] = 1243421; 250 Perfect[ 157 ] = 1245421; 251 Perfect[ 158 ] = 1250521; 252 Perfect[ 159 ] = 1253521; 253 Perfect[ 160 ] = 1257521; 254 Perfect[ 161 ] = 1262621; 255 Perfect[ 162 ] = 1268621; 256 Perfect[ 163 ] = 1273721; 257 Perfect[ 164 ] = 1276721; 258 Perfect[ 165 ] = 1278721; 259 Perfect[ 166 ] = 1280821; 260 Perfect[ 167 ] = 1281821; 261 Perfect[ 168 ] = 1286821; 262 Perfect[ 169 ] = 1287821; 263 Perfect[ 170 ] = 1300031; 264 Perfect[ 171 ] = 1303031; 265 Perfect[ 172 ] = 1311131; 266 Perfect[ 173 ] = 1317131; 267 Perfect[ 174 ] = 1327231; 268 Perfect[ 175 ] = 1328231; 269 Perfect[ 176 ] = 1333331; 270 Perfect[ 177 ] = 1335331; 271 Perfect[ 178 ] = 1338331; 272 Perfect[ 179 ] = 1343431; 273 Perfect[ 180 ] = 1360631; 274 Perfect[ 181 ] = 1362631; 275 Perfect[ 182 ] = 1363631; 276 Perfect[ 183 ] = 1371731; 277 Perfect[ 184 ] = 1374731; 278 Perfect[ 185 ] = 1390931; 279 Perfect[ 186 ] = 1407041; 280 Perfect[ 187 ] = 1409041; 281 Perfect[ 188 ] = 1411141; 282 Perfect[ 189 ] = 1412141; 283 Perfect[ 190 ] = 1422241; 284 Perfect[ 191 ] = 1437341; 285 Perfect[ 192 ] = 1444441; 286 Perfect[ 193 ] = 1447441; 287 Perfect[ 194 ] = 1452541; 288 Perfect[ 195 ] = 1456541; 289 Perfect[ 196 ] = 1461641; 290 Perfect[ 197 ] = 1463641; 291 Perfect[ 198 ] = 1464641; 292 Perfect[ 199 ] = 1469641; 293 Perfect[ 200 ] = 1486841; 294 Perfect[ 201 ] = 1489841; 295 Perfect[ 202 ] = 1490941; 296 Perfect[ 203 ] = 1496941; 297 Perfect[ 204 ] = 1508051; 298 Perfect[ 205 ] = 1513151; 299 Perfect[ 206 ] = 1520251; 300 Perfect[ 207 ] = 1532351; 301 Perfect[ 208 ] = 1535351; 302 Perfect[ 209 ] = 1542451; 303 Perfect[ 210 ] = 1548451; 304 Perfect[ 211 ] = 1550551; 305 Perfect[ 212 ] = 1551551; 306 Perfect[ 213 ] = 1556551; 307 Perfect[ 214 ] = 1557551; 308 Perfect[ 215 ] = 1565651; 309 Perfect[ 216 ] = 1572751; 310 Perfect[ 217 ] = 1579751; 311 Perfect[ 218 ] = 1580851; 312 Perfect[ 219 ] = 1583851; 313 Perfect[ 220 ] = 1589851; 314 Perfect[ 221 ] = 1594951; 315 Perfect[ 222 ] = 1597951; 316 Perfect[ 223 ] = 1598951; 317 Perfect[ 224 ] = 1600061; 318 Perfect[ 225 ] = 1609061; 319 Perfect[ 226 ] = 1611161; 320 Perfect[ 227 ] = 1616161; 321 Perfect[ 228 ] = 1628261; 322 Perfect[ 229 ] = 1630361; 323 Perfect[ 230 ] = 1633361; 324 Perfect[ 231 ] = 1640461; 325 Perfect[ 232 ] = 1643461; 326 Perfect[ 233 ] = 1646461; 327 Perfect[ 234 ] = 1654561; 328 Perfect[ 235 ] = 1657561; 329 Perfect[ 236 ] = 1658561; 330 Perfect[ 237 ] = 1660661; 331 Perfect[ 238 ] = 1670761; 332 Perfect[ 239 ] = 1684861; 333 Perfect[ 240 ] = 1685861; 334 Perfect[ 241 ] = 1688861; 335 Perfect[ 242 ] = 1695961; 336 Perfect[ 243 ] = 1703071; 337 Perfect[ 244 ] = 1707071; 338 Perfect[ 245 ] = 1712171; 339 Perfect[ 246 ] = 1714171; 340 Perfect[ 247 ] = 1730371; 341 Perfect[ 248 ] = 1734371; 342 Perfect[ 249 ] = 1737371; 343 Perfect[ 250 ] = 1748471; 344 Perfect[ 251 ] = 1755571; 345 Perfect[ 252 ] = 1761671; 346 Perfect[ 253 ] = 1764671; 347 Perfect[ 254 ] = 1777771; 348 Perfect[ 255 ] = 1793971; 349 Perfect[ 256 ] = 1802081; 350 Perfect[ 257 ] = 1805081; 351 Perfect[ 258 ] = 1820281; 352 Perfect[ 259 ] = 1823281; 353 Perfect[ 260 ] = 1824281; 354 Perfect[ 261 ] = 1826281; 355 Perfect[ 262 ] = 1829281; 356 Perfect[ 263 ] = 1831381; 357 Perfect[ 264 ] = 1832381; 358 Perfect[ 265 ] = 1842481; 359 Perfect[ 266 ] = 1851581; 360 Perfect[ 267 ] = 1853581; 361 Perfect[ 268 ] = 1856581; 362 Perfect[ 269 ] = 1865681; 363 Perfect[ 270 ] = 1876781; 364 Perfect[ 271 ] = 1878781; 365 Perfect[ 272 ] = 1879781; 366 Perfect[ 273 ] = 1880881; 367 Perfect[ 274 ] = 1881881; 368 Perfect[ 275 ] = 1883881; 369 Perfect[ 276 ] = 1884881; 370 Perfect[ 277 ] = 1895981; 371 Perfect[ 278 ] = 1903091; 372 Perfect[ 279 ] = 1908091; 373 Perfect[ 280 ] = 1909091; 374 Perfect[ 281 ] = 1917191; 375 Perfect[ 282 ] = 1924291; 376 Perfect[ 283 ] = 1930391; 377 Perfect[ 284 ] = 1936391; 378 Perfect[ 285 ] = 1941491; 379 Perfect[ 286 ] = 1951591; 380 Perfect[ 287 ] = 1952591; 381 Perfect[ 288 ] = 1957591; 382 Perfect[ 289 ] = 1958591; 383 Perfect[ 290 ] = 1963691; 384 Perfect[ 291 ] = 1968691; 385 Perfect[ 292 ] = 1969691; 386 Perfect[ 293 ] = 1970791; 387 Perfect[ 294 ] = 1976791; 388 Perfect[ 295 ] = 1981891; 389 Perfect[ 296 ] = 1982891; 390 Perfect[ 297 ] = 1984891; 391 Perfect[ 298 ] = 1987891; 392 Perfect[ 299 ] = 1988891; 393 Perfect[ 300 ] = 1993991; 394 Perfect[ 301 ] = 1995991; 395 Perfect[ 302 ] = 1998991; 396 Perfect[ 303 ] = 3001003; 397 Perfect[ 304 ] = 3002003; 398 Perfect[ 305 ] = 3007003; 399 Perfect[ 306 ] = 3016103; 400 Perfect[ 307 ] = 3026203; 401 Perfect[ 308 ] = 3064603; 402 Perfect[ 309 ] = 3065603; 403 Perfect[ 310 ] = 3072703; 404 Perfect[ 311 ] = 3073703; 405 Perfect[ 312 ] = 3075703; 406 Perfect[ 313 ] = 3083803; 407 Perfect[ 314 ] = 3089803; 408 Perfect[ 315 ] = 3091903; 409 Perfect[ 316 ] = 3095903; 410 Perfect[ 317 ] = 3103013; 411 Perfect[ 318 ] = 3106013; 412 Perfect[ 319 ] = 3127213; 413 Perfect[ 320 ] = 3135313; 414 Perfect[ 321 ] = 3140413; 415 Perfect[ 322 ] = 3155513; 416 Perfect[ 323 ] = 3158513; 417 Perfect[ 324 ] = 3160613; 418 Perfect[ 325 ] = 3166613; 419 Perfect[ 326 ] = 3181813; 420 Perfect[ 327 ] = 3187813; 421 Perfect[ 328 ] = 3193913; 422 Perfect[ 329 ] = 3196913; 423 Perfect[ 330 ] = 3198913; 424 Perfect[ 331 ] = 3211123; 425 Perfect[ 332 ] = 3212123; 426 Perfect[ 333 ] = 3218123; 427 Perfect[ 334 ] = 3222223; 428 Perfect[ 335 ] = 3223223; 429 Perfect[ 336 ] = 3228223; 430 Perfect[ 337 ] = 3233323; 431 Perfect[ 338 ] = 3236323; 432 Perfect[ 339 ] = 3241423; 433 Perfect[ 340 ] = 3245423; 434 Perfect[ 341 ] = 3252523; 435 Perfect[ 342 ] = 3256523; 436 Perfect[ 343 ] = 3258523; 437 Perfect[ 344 ] = 3260623; 438 Perfect[ 345 ] = 3267623; 439 Perfect[ 346 ] = 3272723; 440 Perfect[ 347 ] = 3283823; 441 Perfect[ 348 ] = 3285823; 442 Perfect[ 349 ] = 3286823; 443 Perfect[ 350 ] = 3288823; 444 Perfect[ 351 ] = 3291923; 445 Perfect[ 352 ] = 3293923; 446 Perfect[ 353 ] = 3304033; 447 Perfect[ 354 ] = 3305033; 448 Perfect[ 355 ] = 3307033; 449 Perfect[ 356 ] = 3310133; 450 Perfect[ 357 ] = 3315133; 451 Perfect[ 358 ] = 3319133; 452 Perfect[ 359 ] = 3321233; 453 Perfect[ 360 ] = 3329233; 454 Perfect[ 361 ] = 3331333; 455 Perfect[ 362 ] = 3337333; 456 Perfect[ 363 ] = 3343433; 457 Perfect[ 364 ] = 3353533; 458 Perfect[ 365 ] = 3362633; 459 Perfect[ 366 ] = 3364633; 460 Perfect[ 367 ] = 3365633; 461 Perfect[ 368 ] = 3368633; 462 Perfect[ 369 ] = 3380833; 463 Perfect[ 370 ] = 3391933; 464 Perfect[ 371 ] = 3392933; 465 Perfect[ 372 ] = 3400043; 466 Perfect[ 373 ] = 3411143; 467 Perfect[ 374 ] = 3417143; 468 Perfect[ 375 ] = 3424243; 469 Perfect[ 376 ] = 3425243; 470 Perfect[ 377 ] = 3427243; 471 Perfect[ 378 ] = 3439343; 472 Perfect[ 379 ] = 3441443; 473 Perfect[ 380 ] = 3443443; 474 Perfect[ 381 ] = 3444443; 475 Perfect[ 382 ] = 3447443; 476 Perfect[ 383 ] = 3449443; 477 Perfect[ 384 ] = 3452543; 478 Perfect[ 385 ] = 3460643; 479 Perfect[ 386 ] = 3466643; 480 Perfect[ 387 ] = 3470743; 481 Perfect[ 388 ] = 3479743; 482 Perfect[ 389 ] = 3485843; 483 Perfect[ 390 ] = 3487843; 484 Perfect[ 391 ] = 3503053; 485 Perfect[ 392 ] = 3515153; 486 Perfect[ 393 ] = 3517153; 487 Perfect[ 394 ] = 3528253; 488 Perfect[ 395 ] = 3541453; 489 Perfect[ 396 ] = 3553553; 490 Perfect[ 397 ] = 3558553; 491 Perfect[ 398 ] = 3563653; 492 Perfect[ 399 ] = 3569653; 493 Perfect[ 400 ] = 3586853; 494 Perfect[ 401 ] = 3589853; 495 Perfect[ 402 ] = 3590953; 496 Perfect[ 403 ] = 3591953; 497 Perfect[ 404 ] = 3594953; 498 Perfect[ 405 ] = 3601063; 499 Perfect[ 406 ] = 3607063; 500 Perfect[ 407 ] = 3618163; 501 Perfect[ 408 ] = 3621263; 502 Perfect[ 409 ] = 3627263; 503 Perfect[ 410 ] = 3635363; 504 Perfect[ 411 ] = 3643463; 505 Perfect[ 412 ] = 3646463; 506 Perfect[ 413 ] = 3670763; 507 Perfect[ 414 ] = 3673763; 508 Perfect[ 415 ] = 3680863; 509 Perfect[ 416 ] = 3689863; 510 Perfect[ 417 ] = 3698963; 511 Perfect[ 418 ] = 3708073; 512 Perfect[ 419 ] = 3709073; 513 Perfect[ 420 ] = 3716173; 514 Perfect[ 421 ] = 3717173; 515 Perfect[ 422 ] = 3721273; 516 Perfect[ 423 ] = 3722273; 517 Perfect[ 424 ] = 3728273; 518 Perfect[ 425 ] = 3732373; 519 Perfect[ 426 ] = 3743473; 520 Perfect[ 427 ] = 3746473; 521 Perfect[ 428 ] = 3762673; 522 Perfect[ 429 ] = 3763673; 523 Perfect[ 430 ] = 3765673; 524 Perfect[ 431 ] = 3768673; 525 Perfect[ 432 ] = 3769673; 526 Perfect[ 433 ] = 3773773; 527 Perfect[ 434 ] = 3774773; 528 Perfect[ 435 ] = 3781873; 529 Perfect[ 436 ] = 3784873; 530 Perfect[ 437 ] = 3792973; 531 Perfect[ 438 ] = 3793973; 532 Perfect[ 439 ] = 3799973; 533 Perfect[ 440 ] = 3804083; 534 Perfect[ 441 ] = 3806083; 535 Perfect[ 442 ] = 3812183; 536 Perfect[ 443 ] = 3814183; 537 Perfect[ 444 ] = 3826283; 538 Perfect[ 445 ] = 3829283; 539 Perfect[ 446 ] = 3836383; 540 Perfect[ 447 ] = 3842483; 541 Perfect[ 448 ] = 3853583; 542 Perfect[ 449 ] = 3858583; 543 Perfect[ 450 ] = 3863683; 544 Perfect[ 451 ] = 3864683; 545 Perfect[ 452 ] = 3867683; 546 Perfect[ 453 ] = 3869683; 547 Perfect[ 454 ] = 3871783; 548 Perfect[ 455 ] = 3878783; 549 Perfect[ 456 ] = 3893983; 550 Perfect[ 457 ] = 3899983; 551 Perfect[ 458 ] = 3913193; 552 Perfect[ 459 ] = 3916193; 553 Perfect[ 460 ] = 3918193; 554 Perfect[ 461 ] = 3924293; 555 Perfect[ 462 ] = 3927293; 556 Perfect[ 463 ] = 3931393; 557 Perfect[ 464 ] = 3938393; 558 Perfect[ 465 ] = 3942493; 559 Perfect[ 466 ] = 3946493; 560 Perfect[ 467 ] = 3948493; 561 Perfect[ 468 ] = 3964693; 562 Perfect[ 469 ] = 3970793; 563 Perfect[ 470 ] = 3983893; 564 Perfect[ 471 ] = 3991993; 565 Perfect[ 472 ] = 3994993; 566 Perfect[ 473 ] = 3997993; 567 Perfect[ 474 ] = 3998993; 568 Perfect[ 475 ] = 7014107; 569 Perfect[ 476 ] = 7035307; 570 Perfect[ 477 ] = 7036307; 571 Perfect[ 478 ] = 7041407; 572 Perfect[ 479 ] = 7046407; 573 Perfect[ 480 ] = 7057507; 574 Perfect[ 481 ] = 7065607; 575 Perfect[ 482 ] = 7069607; 576 Perfect[ 483 ] = 7073707; 577 Perfect[ 484 ] = 7079707; 578 Perfect[ 485 ] = 7082807; 579 Perfect[ 486 ] = 7084807; 580 Perfect[ 487 ] = 7087807; 581 Perfect[ 488 ] = 7093907; 582 Perfect[ 489 ] = 7096907; 583 Perfect[ 490 ] = 7100017; 584 Perfect[ 491 ] = 7114117; 585 Perfect[ 492 ] = 7115117; 586 Perfect[ 493 ] = 7118117; 587 Perfect[ 494 ] = 7129217; 588 Perfect[ 495 ] = 7134317; 589 Perfect[ 496 ] = 7136317; 590 Perfect[ 497 ] = 7141417; 591 Perfect[ 498 ] = 7145417; 592 Perfect[ 499 ] = 7155517; 593 Perfect[ 500 ] = 7156517; 594 Perfect[ 501 ] = 7158517; 595 Perfect[ 502 ] = 7159517; 596 Perfect[ 503 ] = 7177717; 597 Perfect[ 504 ] = 7190917; 598 Perfect[ 505 ] = 7194917; 599 Perfect[ 506 ] = 7215127; 600 Perfect[ 507 ] = 7226227; 601 Perfect[ 508 ] = 7246427; 602 Perfect[ 509 ] = 7249427; 603 Perfect[ 510 ] = 7250527; 604 Perfect[ 511 ] = 7256527; 605 Perfect[ 512 ] = 7257527; 606 Perfect[ 513 ] = 7261627; 607 Perfect[ 514 ] = 7267627; 608 Perfect[ 515 ] = 7276727; 609 Perfect[ 516 ] = 7278727; 610 Perfect[ 517 ] = 7291927; 611 Perfect[ 518 ] = 7300037; 612 Perfect[ 519 ] = 7302037; 613 Perfect[ 520 ] = 7310137; 614 Perfect[ 521 ] = 7314137; 615 Perfect[ 522 ] = 7324237; 616 Perfect[ 523 ] = 7327237; 617 Perfect[ 524 ] = 7347437; 618 Perfect[ 525 ] = 7352537; 619 Perfect[ 526 ] = 7354537; 620 Perfect[ 527 ] = 7362637; 621 Perfect[ 528 ] = 7365637; 622 Perfect[ 529 ] = 7381837; 623 Perfect[ 530 ] = 7388837; 624 Perfect[ 531 ] = 7392937; 625 Perfect[ 532 ] = 7401047; 626 Perfect[ 533 ] = 7403047; 627 Perfect[ 534 ] = 7409047; 628 Perfect[ 535 ] = 7415147; 629 Perfect[ 536 ] = 7434347; 630 Perfect[ 537 ] = 7436347; 631 Perfect[ 538 ] = 7439347; 632 Perfect[ 539 ] = 7452547; 633 Perfect[ 540 ] = 7461647; 634 Perfect[ 541 ] = 7466647; 635 Perfect[ 542 ] = 7472747; 636 Perfect[ 543 ] = 7475747; 637 Perfect[ 544 ] = 7485847; 638 Perfect[ 545 ] = 7486847; 639 Perfect[ 546 ] = 7489847; 640 Perfect[ 547 ] = 7493947; 641 Perfect[ 548 ] = 7507057; 642 Perfect[ 549 ] = 7508057; 643 Perfect[ 550 ] = 7518157; 644 Perfect[ 551 ] = 7519157; 645 Perfect[ 552 ] = 7521257; 646 Perfect[ 553 ] = 7527257; 647 Perfect[ 554 ] = 7540457; 648 Perfect[ 555 ] = 7562657; 649 Perfect[ 556 ] = 7564657; 650 Perfect[ 557 ] = 7576757; 651 Perfect[ 558 ] = 7586857; 652 Perfect[ 559 ] = 7592957; 653 Perfect[ 560 ] = 7594957; 654 Perfect[ 561 ] = 7600067; 655 Perfect[ 562 ] = 7611167; 656 Perfect[ 563 ] = 7619167; 657 Perfect[ 564 ] = 7622267; 658 Perfect[ 565 ] = 7630367; 659 Perfect[ 566 ] = 7632367; 660 Perfect[ 567 ] = 7644467; 661 Perfect[ 568 ] = 7654567; 662 Perfect[ 569 ] = 7662667; 663 Perfect[ 570 ] = 7665667; 664 Perfect[ 571 ] = 7666667; 665 Perfect[ 572 ] = 7668667; 666 Perfect[ 573 ] = 7669667; 667 Perfect[ 574 ] = 7674767; 668 Perfect[ 575 ] = 7681867; 669 Perfect[ 576 ] = 7690967; 670 Perfect[ 577 ] = 7693967; 671 Perfect[ 578 ] = 7696967; 672 Perfect[ 579 ] = 7715177; 673 Perfect[ 580 ] = 7718177; 674 Perfect[ 581 ] = 7722277; 675 Perfect[ 582 ] = 7729277; 676 Perfect[ 583 ] = 7733377; 677 Perfect[ 584 ] = 7742477; 678 Perfect[ 585 ] = 7747477; 679 Perfect[ 586 ] = 7750577; 680 Perfect[ 587 ] = 7758577; 681 Perfect[ 588 ] = 7764677; 682 Perfect[ 589 ] = 7772777; 683 Perfect[ 590 ] = 7774777; 684 Perfect[ 591 ] = 7778777; 685 Perfect[ 592 ] = 7782877; 686 Perfect[ 593 ] = 7783877; 687 Perfect[ 594 ] = 7791977; 688 Perfect[ 595 ] = 7794977; 689 Perfect[ 596 ] = 7807087; 690 Perfect[ 597 ] = 7819187; 691 Perfect[ 598 ] = 7820287; 692 Perfect[ 599 ] = 7821287; 693 Perfect[ 600 ] = 7831387; 694 Perfect[ 601 ] = 7832387; 695 Perfect[ 602 ] = 7838387; 696 Perfect[ 603 ] = 7843487; 697 Perfect[ 604 ] = 7850587; 698 Perfect[ 605 ] = 7856587; 699 Perfect[ 606 ] = 7865687; 700 Perfect[ 607 ] = 7867687; 701 Perfect[ 608 ] = 7868687; 702 Perfect[ 609 ] = 7873787; 703 Perfect[ 610 ] = 7884887; 704 Perfect[ 611 ] = 7891987; 705 Perfect[ 612 ] = 7897987; 706 Perfect[ 613 ] = 7913197; 707 Perfect[ 614 ] = 7916197; 708 Perfect[ 615 ] = 7930397; 709 Perfect[ 616 ] = 7933397; 710 Perfect[ 617 ] = 7935397; 711 Perfect[ 618 ] = 7938397; 712 Perfect[ 619 ] = 7941497; 713 Perfect[ 620 ] = 7943497; 714 Perfect[ 621 ] = 7949497; 715 Perfect[ 622 ] = 7957597; 716 Perfect[ 623 ] = 7958597; 717 Perfect[ 624 ] = 7960697; 718 Perfect[ 625 ] = 7977797; 719 Perfect[ 626 ] = 7984897; 720 Perfect[ 627 ] = 7985897; 721 Perfect[ 628 ] = 7987897; 722 Perfect[ 629 ] = 7996997; 723 Perfect[ 630 ] = 9002009; 724 Perfect[ 631 ] = 9015109; 725 Perfect[ 632 ] = 9024209; 726 Perfect[ 633 ] = 9037309; 727 Perfect[ 634 ] = 9042409; 728 Perfect[ 635 ] = 9043409; 729 Perfect[ 636 ] = 9045409; 730 Perfect[ 637 ] = 9046409; 731 Perfect[ 638 ] = 9049409; 732 Perfect[ 639 ] = 9067609; 733 Perfect[ 640 ] = 9073709; 734 Perfect[ 641 ] = 9076709; 735 Perfect[ 642 ] = 9078709; 736 Perfect[ 643 ] = 9091909; 737 Perfect[ 644 ] = 9095909; 738 Perfect[ 645 ] = 9103019; 739 Perfect[ 646 ] = 9109019; 740 Perfect[ 647 ] = 9110119; 741 Perfect[ 648 ] = 9127219; 742 Perfect[ 649 ] = 9128219; 743 Perfect[ 650 ] = 9136319; 744 Perfect[ 651 ] = 9149419; 745 Perfect[ 652 ] = 9169619; 746 Perfect[ 653 ] = 9173719; 747 Perfect[ 654 ] = 9174719; 748 Perfect[ 655 ] = 9179719; 749 Perfect[ 656 ] = 9185819; 750 Perfect[ 657 ] = 9196919; 751 Perfect[ 658 ] = 9199919; 752 Perfect[ 659 ] = 9200029; 753 Perfect[ 660 ] = 9209029; 754 Perfect[ 661 ] = 9212129; 755 Perfect[ 662 ] = 9217129; 756 Perfect[ 663 ] = 9222229; 757 Perfect[ 664 ] = 9223229; 758 Perfect[ 665 ] = 9230329; 759 Perfect[ 666 ] = 9231329; 760 Perfect[ 667 ] = 9255529; 761 Perfect[ 668 ] = 9269629; 762 Perfect[ 669 ] = 9271729; 763 Perfect[ 670 ] = 9277729; 764 Perfect[ 671 ] = 9280829; 765 Perfect[ 672 ] = 9286829; 766 Perfect[ 673 ] = 9289829; 767 Perfect[ 674 ] = 9318139; 768 Perfect[ 675 ] = 9320239; 769 Perfect[ 676 ] = 9324239; 770 Perfect[ 677 ] = 9329239; 771 Perfect[ 678 ] = 9332339; 772 Perfect[ 679 ] = 9338339; 773 Perfect[ 680 ] = 9351539; 774 Perfect[ 681 ] = 9357539; 775 Perfect[ 682 ] = 9375739; 776 Perfect[ 683 ] = 9384839; 777 Perfect[ 684 ] = 9397939; 778 Perfect[ 685 ] = 9400049; 779 Perfect[ 686 ] = 9414149; 780 Perfect[ 687 ] = 9419149; 781 Perfect[ 688 ] = 9433349; 782 Perfect[ 689 ] = 9439349; 783 Perfect[ 690 ] = 9440449; 784 Perfect[ 691 ] = 9446449; 785 Perfect[ 692 ] = 9451549; 786 Perfect[ 693 ] = 9470749; 787 Perfect[ 694 ] = 9477749; 788 Perfect[ 695 ] = 9492949; 789 Perfect[ 696 ] = 9493949; 790 Perfect[ 697 ] = 9495949; 791 Perfect[ 698 ] = 9504059; 792 Perfect[ 699 ] = 9514159; 793 Perfect[ 700 ] = 9526259; 794 Perfect[ 701 ] = 9529259; 795 Perfect[ 702 ] = 9547459; 796 Perfect[ 703 ] = 9556559; 797 Perfect[ 704 ] = 9558559; 798 Perfect[ 705 ] = 9561659; 799 Perfect[ 706 ] = 9577759; 800 Perfect[ 707 ] = 9583859; 801 Perfect[ 708 ] = 9585859; 802 Perfect[ 709 ] = 9586859; 803 Perfect[ 710 ] = 9601069; 804 Perfect[ 711 ] = 9602069; 805 Perfect[ 712 ] = 9604069; 806 Perfect[ 713 ] = 9610169; 807 Perfect[ 714 ] = 9620269; 808 Perfect[ 715 ] = 9624269; 809 Perfect[ 716 ] = 9626269; 810 Perfect[ 717 ] = 9632369; 811 Perfect[ 718 ] = 9634369; 812 Perfect[ 719 ] = 9645469; 813 Perfect[ 720 ] = 9650569; 814 Perfect[ 721 ] = 9657569; 815 Perfect[ 722 ] = 9670769; 816 Perfect[ 723 ] = 9686869; 817 Perfect[ 724 ] = 9700079; 818 Perfect[ 725 ] = 9709079; 819 Perfect[ 726 ] = 9711179; 820 Perfect[ 727 ] = 9714179; 821 Perfect[ 728 ] = 9724279; 822 Perfect[ 729 ] = 9727279; 823 Perfect[ 730 ] = 9732379; 824 Perfect[ 731 ] = 9733379; 825 Perfect[ 732 ] = 9743479; 826 Perfect[ 733 ] = 9749479; 827 Perfect[ 734 ] = 9752579; 828 Perfect[ 735 ] = 9754579; 829 Perfect[ 736 ] = 9758579; 830 Perfect[ 737 ] = 9762679; 831 Perfect[ 738 ] = 9770779; 832 Perfect[ 739 ] = 9776779; 833 Perfect[ 740 ] = 9779779; 834 Perfect[ 741 ] = 9781879; 835 Perfect[ 742 ] = 9782879; 836 Perfect[ 743 ] = 9787879; 837 Perfect[ 744 ] = 9788879; 838 Perfect[ 745 ] = 9795979; 839 Perfect[ 746 ] = 9801089; 840 Perfect[ 747 ] = 9807089; 841 Perfect[ 748 ] = 9809089; 842 Perfect[ 749 ] = 9817189; 843 Perfect[ 750 ] = 9818189; 844 Perfect[ 751 ] = 9820289; 845 Perfect[ 752 ] = 9822289; 846 Perfect[ 753 ] = 9836389; 847 Perfect[ 754 ] = 9837389; 848 Perfect[ 755 ] = 9845489; 849 Perfect[ 756 ] = 9852589; 850 Perfect[ 757 ] = 9871789; 851 Perfect[ 758 ] = 9888889; 852 Perfect[ 759 ] = 9889889; 853 Perfect[ 760 ] = 9896989; 854 Perfect[ 761 ] = 9902099; 855 Perfect[ 762 ] = 9907099; 856 Perfect[ 763 ] = 9908099; 857 Perfect[ 764 ] = 9916199; 858 Perfect[ 765 ] = 9918199; 859 Perfect[ 766 ] = 9919199; 860 Perfect[ 767 ] = 9921299; 861 Perfect[ 768 ] = 9923299; 862 Perfect[ 769 ] = 9926299; 863 Perfect[ 770 ] = 9927299; 864 Perfect[ 771 ] = 9931399; 865 Perfect[ 772 ] = 9932399; 866 Perfect[ 773 ] = 9935399; 867 Perfect[ 774 ] = 9938399; 868 Perfect[ 775 ] = 9957599; 869 Perfect[ 776 ] = 9965699; 870 Perfect[ 777 ] = 9978799; 871 Perfect[ 778 ] = 9980899; 872 Perfect[ 779 ] = 9981899; 873 Perfect[ 780 ] = 9989899; 874 } 875 876 int main(){ 877 //freopen("out.txt","w",stdout); 878 //initPrime(); 879 //initPerfect(); 880 int L,R; 881 init(); 882 int cntPerfect = 781; 883 while( scanf("%d%d",&L,&R)==2 ){ 884 if( L>R ) swap( L,R ); 885 for( int i=0;i<cntPerfect;i++ ){ 886 if( Perfect[ i ]>=L && Perfect[ i ]<=R ){ 887 printf("%d\n",Perfect[ i ]); 888 } 889 else if( Perfect[ i ]>R ) break; 890 } 891 printf("\n"); 892 } 893 return 0; 894 }
keep moving...