hdu2089

枚举法。。。。

View Code
   
     
#include " iostream "
#define M 1000001
using namespace std;
int a[M];
int main()
{
int m,n;
int i;
memset(a,
0 , sizeof (a));
for (i = 1 ;i <= 1000001 ;i ++ )
{
int x = i;
int k = i;
while (x)
{
if (x % 10 == 4 || x % 100 == 62 ){ a[k] = 1 ; }
x
/= 10 ;
}
}
while (cin >> m >> n,m + n)
{
int flag = 0 ;
for (i = m;i <= n;i ++ )
if (a[i] == 1 ) flag ++ ;
printf(
" %d\n " ,n - m - flag + 1 );
}
return 0 ;
}

你可能感兴趣的:(HDU)