HDU 2089 不要62 | 暴力(其实是个DP)

题目:

http://acm.hdu.edu.cn/showproblem.php?pid=2089


题解:

暴力水过

#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e6+5;
int n,m;
int f[N];
bool check(int x)
{
  while(x)
    {
      if(x%100==62||x%10==4) return 0;
      x/=10;
    }
  return 1;
}
void init()
{
  for(int i=1;i<=1e6;i++) f[i]=f[i-1]+check(i);
}
int main()
{
  init();
  while(~scanf("%d%d",&n,&m) && n+m)  printf("%d\n",f[m]-f[n-1]);
  return 0;
}

 

posted @ 2018-01-09 11:20  MSPqwq  阅读(167)  评论(0编辑  收藏  举报