求解思路是把数字转换成字符串,进行判断,级数
public class Test {
public static void main(String args [])
{
TheLuckyNumbersLevelOne a = new TheLuckyNumbersLevelOne();
System.out.println(a.find(4567823,7891456));
}
}
class TheLuckyNumbersLevelOne
{
public long find(long a, long b)
{
long count=0;
for(long x=a;x<=b;x++)
{
if(confirm(x))
count++;
}
return count;
}
private boolean confirm(long a)
{
String s = String.valueOf(a);
if(s.length()==1)
if(s.charAt(0)==‘4‘||s.charAt(0)==‘7‘)
return true;
else
return false;
for(int x = 0;x<s.length()/2;x++)
{
if((s.charAt(x)==‘4‘||s.charAt(x)==‘7‘)&&s.charAt(x)==s.charAt(s.length()-x-1))
;
else
{
return false;
}
}
if(s.charAt(s.length()/2)==‘4‘||s.charAt(s.length()/2)==‘7‘)
return true;
else return false;
}
}