杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
62315 73418 88914
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了。
 
Input
输入的都是整数对n、m(0<n≤m<1000000),如果遇到都是0的整数对,则输入结束。
 
Output
对于每个整数对,输出一个不含有不吉利数字的统计个数,该数值占一行位置。
 
Sample Input
1 100
0 0
 
Sample Output
80

数位dp

要记一下上一位是不是6

  1. #include<cstdio>
  2. #include<iostream>
  3. #include<cstring>
  4. #include<cstdlib>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<queue>
  8. #include<deque>
  9. #include<set>
  10. #include<map>
  11. #include<ctime>
  12. #define LL long long
  13. #define inf 0x7ffffff
  14. #define pa pair<int,int>
  15. #define mkp(a,b) make_pair(a,b)
  16. #define pi 3.1415926535897932384626433832795028841971
  17. using namespace std;
  18. inline LL read()
  19. {
  20. LL x=,f=;char ch=getchar();
  21. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  22. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  23. return x*f;
  24. }
  25. LL l,r,len;
  26. LL f[][];
  27. int d[];
  28. inline int dfs(int now,int lst,int fp)
  29. {
  30. if (now==)return ;
  31. if (!fp&&f[now][lst]!=-)return f[now][lst];
  32. LL ans=,mx=(fp?d[now-]:);
  33. for (int i=;i<=mx;i++)
  34. {
  35. if (lst==&&i==||i==)continue;
  36. ans+=dfs(now-,i,fp&&mx==i);
  37. }
  38. if (!fp&&f[now][lst]==-)f[now][lst]=ans;
  39. return ans;
  40. }
  41. inline LL calc(LL x)
  42. {
  43. if (x==-)return ;
  44. if (x==)return ;
  45. LL xxx=x;
  46. len=;
  47. while (xxx)
  48. {
  49. d[++len]=xxx%;
  50. xxx/=;
  51. }
  52. LL sum=;
  53. for (int i=;i<=d[len];i++)
  54. if (i!=)sum+=dfs(len,i,i==d[len]);
  55. return sum;
  56. }
  57. int main()
  58. {
  59. memset(f,-,sizeof(f));
  60. while (~scanf("%d%d",&l,&r)&&l+r)printf("%lld\n",calc(r)-calc(l-));
  61. }

hdu 2089

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define mkp(a,b) make_pair(a,b)
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
    LL x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
LL n,len;
LL f[20][13][10][2];
int d[20];
inline int dfs(int now,int rest,int dat,int sat,int fp)
{
if (now==1)return !rest&&sat;
if (!fp&&f[now][rest][dat][sat]!=-1)return f[now][rest][dat][sat];
LL ans=0,mx=(fp?d[now-1]:9);
for (int i=0;i<=mx;i++)
{
if (sat||!sat&&dat==1&&i==3)ans+=dfs(now-1,(rest*10+i)%13,i,1,fp&&mx==i);
else ans+=dfs(now-1,(rest*10+i)%13,i,0,fp&&mx==i);
}
if (!fp&&f[now][rest][dat][sat]==-1)f[now][rest][dat][sat]=ans;
return ans;
}
inline LL calc(LL x)
{
LL xxx=x;
len=0;
while (xxx)
{
d[++len]=xxx%10;
xxx/=10;
}
LL sum=0;
for (int i=0;i<=d[len];i++)
sum+=dfs(len,i,i,0,i==d[len]);
return sum;
}
int main()
{
memset(f,-1,sizeof(f));
while (scanf("%d",&n)!=EOF)printf("%lld\n",calc(n));
}

[暑假集训--数位dp]hdu2089 不要62的更多相关文章

  1. [暑假集训--数位dp]LightOj1205 Palindromic Numbers

    A palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the sam ...

  2. [暑假集训--数位dp]hdu3709 Balanced Number

    A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. ...

  3. [暑假集训--数位dp]hdu3555 Bomb

    The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the ti ...

  4. [暑假集训--数位dp]hdu3652 B-number

    A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- ...

  5. [暑假集训--数位dp]hdu5787 K-wolf Number

    Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation o ...

  6. [暑假集训--数位dp]UESTC250 windy数

    windy定义了一种windy数. 不含前导零且相邻两个数字之差至少为22 的正整数被称为windy数. windy想知道,在AA 和BB 之间,包括AA 和BB ,总共有多少个windy数? Inp ...

  7. [暑假集训--数位dp]LightOJ1140 How Many Zeroes?

    Jimmy writes down the decimal representations of all natural numbers between and including m and n, ...

  8. [暑假集训--数位dp]LightOj1032 Fast Bit Calculations

    A bit is a binary digit, taking a logical value of either 1 or 0 (also referred to as "true&quo ...

  9. [暑假集训--数位dp]hdu5898 odd-even number

    For a number,if the length of continuous odd digits is even and the length of continuous even digits ...

随机推荐

  1. centos中安装elasticsearch5.0

    1.安装jdk 可以直接安装自带的openjdk,安装完成之后修改一下java的环境变量.另一种方式是就是安装oracle的jdk,从官网上下载http://www.oracle.com/techne ...

  2. 更新Svn客户端后,右键菜单中没有TortoiseSVN

    环境: OS:                 Windows XP sp3 升级后SVNServer:    VisualSVN Server 2.7.3 升级后SVNClient:    小乌龟: ...

  3. mac上使用命令行显示隐藏文件

    终端中输入命令 打开<终端> - 粘贴下面的两行命令执行 defaults write com.apple.finder AppleShowAllFiles TRUEkillall Fin ...

  4. jQuery筛选器及练习

    jQuery初识   jQuery是什么? jQuery是一个兼容多浏览器的JavaScript库. jQuery能极大地简化JavaScript编程,它的宗旨就是:"Write less, ...

  5. [JOYOI] 1035 棋盘覆盖

    题目限制 时间限制 内存限制 评测方式 题目来源 1000ms 131072KiB 标准比较器 Local 题目描述 给出一张nn(n<=100)的国际象棋棋盘,其中被删除了一些点,问可以使用多 ...

  6. mysql基本优化

    文件打开数 show status like "%Open_files%" Open_files 133 show VARIABLES like "%open_files ...

  7. (3)zabbix用户管理

    登陆zabbix 默认账号:Admin,密码:zabbix,这是一个超级管理员.登陆之后在右下角可以看到“connected as Admin“(中文版:连接为Admin). zabbix组介绍 我们 ...

  8. js中小数精度问题

    js中小数的取值为近似值,可能比实际值大,也可能比实际值小,进行“四舍五入”得到的 例如:alert(0.1+0.2);值为0.300000004     alert(0.2+0.7);值为1.899 ...

  9. Python3与SQLServer、Oracle、MySql的连接方法

    环境: python3.4 64bit pycharm2018社区版 64bit Oracle 11 64bit SQLServer· Mysql 其中三种不同的数据库安装在不同的服务器上,通过局域网 ...

  10. LeetCode(79) Word Search

    题目 Given a 2D board and a word, find if the word exists in the grid. The word can be constructed fro ...