回文素数+火柴棒等式

通过运行【5,100000000】之内的回文素数,发现规律:

5 100000000

 

 

回文素数没有4、6、8位的,虽然数的范围是到100,000,000,但是最后一个数只到9989899为止(七位数)。所以直接加一个

if(i>=10000000) return 0;

就可以AC了。

 

 

 火柴棒

 

 

 

 

24

0(6) + 8(7) = 8(7)总共20根火柴

0(6) + 12(7) = 12(7)总共20根火柴

0(6) + 13(7) = 13(7)总共20根火柴

0(6) + 15(7) = 15(7)总共20根火柴

0(6) + 21(7) = 21(7)总共20根火柴

0(6) + 31(7) = 31(7)总共20根火柴

0(6) + 47(7) = 47(7)总共20根火柴

0(6) + 51(7) = 51(7)总共20根火柴

0(6) + 74(7) = 74(7)总共20根火柴

0(6) + 117(7) = 117(7)总共20根火柴

0(6) + 171(7) = 171(7)总共20根火柴

0(6) + 711(7) = 711(7)总共20根火柴

1(2) + 20(11) = 21(7)总共20根火柴

1(2) + 30(11) = 31(7)总共20根火柴

1(2) + 42(9) = 43(9)总共20根火柴

1(2) + 47(7) = 48(11)总共20根火柴

1(2) + 50(11) = 51(7)总共20根火柴

1(2) + 112(9) = 113(9)总共20根火柴

1(2) + 117(7) = 118(11)总共20根火柴

1(2) + 170(11) = 171(7)总共20根火柴

1(2) + 710(11) = 711(7)总共20根火柴

2(5) + 8(7) = 10(8)总共20根火柴

2(5) + 10(8) = 12(7)总共20根火柴

2(5) + 19(8) = 21(7)总共20根火柴

2(5) + 41(6) = 43(9)总共20根火柴

2(5) + 72(8) = 74(7)总共20根火柴

2(5) + 77(6) = 79(9)总共20根火柴

2(5) + 111(6) = 113(9)总共20根火柴

3(5) + 10(8) = 13(7)总共20根火柴

3(5) + 13(7) = 16(8)总共20根火柴

3(5) + 44(8) = 47(7)总共20根火柴

3(5) + 114(8) = 117(7)总共20根火柴

4(4) + 43(9) = 47(7)总共20根火柴

4(4) + 57(8) = 61(8)总共20根火柴

4(4) + 70(9) = 74(7)总共20根火柴

4(4) + 113(9) = 117(7)总共20根火柴

4(4) + 117(7) = 121(9)总共20根火柴

5(5) + 10(8) = 15(7)总共20根火柴

5(5) + 16(8) = 21(7)总共20根火柴

5(5) + 17(5) = 22(10)总共20根火柴

6(6) + 15(7) = 21(7)总共20根火柴

7(3) + 15(7) = 22(10)总共20根火柴

7(3) + 27(8) = 34(9)总共20根火柴

7(3) + 40(10) = 47(7)总共20根火柴

7(3) + 41(6) = 48(11)总共20根火柴

7(3) + 54(9) = 61(8)总共20根火柴

7(3) + 72(8) = 79(9)总共20根火柴

7(3) + 77(6) = 84(11)总共20根火柴

7(3) + 110(10) = 117(7)总共20根火柴

7(3) + 111(6) = 118(11)总共20根火柴

7(3) + 114(8) = 121(9)总共20根火柴

8(7) + 0(6) = 8(7)总共20根火柴

8(7) + 2(5) = 10(8)总共20根火柴

9(6) + 12(7) = 21(7)总共20根火柴

10(8) + 2(5) = 12(7)总共20根火柴

10(8) + 3(5) = 13(7)总共20根火柴

10(8) + 5(5) = 15(7)总共20根火柴

11(4) + 13(7) = 24(9)总共20根火柴

11(4) + 14(6) = 25(10)总共20根火柴

11(4) + 16(8) = 27(8)总共20根火柴

11(4) + 31(7) = 42(9)总共20根火柴

11(4) + 41(6) = 52(10)总共20根火柴

11(4) + 61(8) = 72(8)总共20根火柴

12(7) + 0(6) = 12(7)总共20根火柴

12(7) + 9(6) = 21(7)总共20根火柴

13(7) + 0(6) = 13(7)总共20根火柴

13(7) + 3(5) = 16(8)总共20根火柴

13(7) + 11(4) = 24(9)总共20根火柴

14(6) + 11(4) = 25(10)总共20根火柴

14(6) + 27(8) = 41(6)总共20根火柴

14(6) + 77(6) = 91(8)总共20根火柴

15(7) + 0(6) = 15(7)总共20根火柴

15(7) + 6(6) = 21(7)总共20根火柴

15(7) + 7(3) = 22(10)总共20根火柴

16(8) + 5(5) = 21(7)总共20根火柴

16(8) + 11(4) = 27(8)总共20根火柴

17(5) + 5(5) = 22(10)总共20根火柴

17(5) + 24(9) = 41(6)总共20根火柴

17(5) + 57(8) = 74(7)总共20根火柴

17(5) + 74(7) = 91(8)总共20根火柴

19(8) + 2(5) = 21(7)总共20根火柴

20(11) + 1(2) = 21(7)总共20根火柴

21(7) + 0(6) = 21(7)总共20根火柴

24(9) + 17(5) = 41(6)总共20根火柴

27(8) + 7(3) = 34(9)总共20根火柴

27(8) + 14(6) = 41(6)总共20根火柴

30(11) + 1(2) = 31(7)总共20根火柴

31(7) + 0(6) = 31(7)总共20根火柴

31(7) + 11(4) = 42(9)总共20根火柴

40(10) + 7(3) = 47(7)总共20根火柴

41(6) + 2(5) = 43(9)总共20根火柴

41(6) + 7(3) = 48(11)总共20根火柴

41(6) + 11(4) = 52(10)总共20根火柴

41(6) + 71(5) = 112(9)总共20根火柴

42(9) + 1(2) = 43(9)总共20根火柴

43(9) + 4(4) = 47(7)总共20根火柴

44(8) + 3(5) = 47(7)总共20根火柴

47(7) + 0(6) = 47(7)总共20根火柴

47(7) + 1(2) = 48(11)总共20根火柴

50(11) + 1(2) = 51(7)总共20根火柴

51(7) + 0(6) = 51(7)总共20根火柴

54(9) + 7(3) = 61(8)总共20根火柴

57(8) + 4(4) = 61(8)总共20根火柴

57(8) + 17(5) = 74(7)总共20根火柴

61(8) + 11(4) = 72(8)总共20根火柴

70(9) + 4(4) = 74(7)总共20根火柴

71(5) + 41(6) = 112(9)总共20根火柴

72(8) + 2(5) = 74(7)总共20根火柴

72(8) + 7(3) = 79(9)总共20根火柴

74(7) + 0(6) = 74(7)总共20根火柴

74(7) + 17(5) = 91(8)总共20根火柴

77(6) + 2(5) = 79(9)总共20根火柴

77(6) + 7(3) = 84(11)总共20根火柴

77(6) + 14(6) = 91(8)总共20根火柴

110(10) + 7(3) = 117(7)总共20根火柴

111(6) + 2(5) = 113(9)总共20根火柴

111(6) + 7(3) = 118(11)总共20根火柴

112(9) + 1(2) = 113(9)总共20根火柴

113(9) + 4(4) = 117(7)总共20根火柴

114(8) + 3(5) = 117(7)总共20根火柴

114(8) + 7(3) = 121(9)总共20根火柴

117(7) + 0(6) = 117(7)总共20根火柴

117(7) + 1(2) = 118(11)总共20根火柴

117(7) + 4(4) = 121(9)总共20根火柴

170(11) + 1(2) = 171(7)总共20根火柴

171(7) + 0(6) = 171(7)总共20根火柴

710(11) + 1(2) = 711(7)总共20根火柴

711(7) + 0(6) = 711(7)总共20根火柴

128

Program ended with exit code: 0

 三连击升级版:

 

 

 

要特判一个特例123 456 789.

posted @ 2020-03-16 14:57  龙雪可可  阅读(375)  评论(0编辑  收藏  举报
****************************************** 页脚Html代码 ******************************************