[暑假集训--数位dp]hdu2089 不要62
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
62315 73418 88914
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了。
0 0
数位dp
要记一下上一位是不是6
#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=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
LL l,r,len;
LL f[][];
int d[];
inline int dfs(int now,int lst,int fp)
{
if (now==)return ;
if (!fp&&f[now][lst]!=-)return f[now][lst];
LL ans=,mx=(fp?d[now-]:);
for (int i=;i<=mx;i++)
{
if (lst==&&i==||i==)continue;
ans+=dfs(now-,i,fp&&mx==i);
}
if (!fp&&f[now][lst]==-)f[now][lst]=ans;
return ans;
}
inline LL calc(LL x)
{
if (x==-)return ;
if (x==)return ;
LL xxx=x;
len=;
while (xxx)
{
d[++len]=xxx%;
xxx/=;
}
LL sum=;
for (int i=;i<=d[len];i++)
if (i!=)sum+=dfs(len,i,i==d[len]);
return sum;
}
int main()
{
memset(f,-,sizeof(f));
while (~scanf("%d%d",&l,&r)&&l+r)printf("%lld\n",calc(r)-calc(l-));
}
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的更多相关文章
- [暑假集训--数位dp]LightOj1205 Palindromic Numbers
		
A palindromic number or numeral palindrome is a 'symmetrical' number like 16461 that remains the sam ...
 - [暑假集训--数位dp]hdu3709 Balanced Number
		
A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. ...
 - [暑假集训--数位dp]hdu3555 Bomb
		
The counter-terrorists found a time bomb in the dust. But this time the terrorists improve on the ti ...
 - [暑假集训--数位dp]hdu3652 B-number
		
A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- ...
 - [暑假集训--数位dp]hdu5787 K-wolf Number
		
Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation o ...
 - [暑假集训--数位dp]UESTC250 windy数
		
windy定义了一种windy数. 不含前导零且相邻两个数字之差至少为22 的正整数被称为windy数. windy想知道,在AA 和BB 之间,包括AA 和BB ,总共有多少个windy数? Inp ...
 - [暑假集训--数位dp]LightOJ1140 How Many Zeroes?
		
Jimmy writes down the decimal representations of all natural numbers between and including m and n, ...
 - [暑假集训--数位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 ...
 - [暑假集训--数位dp]hdu5898 odd-even number
		
For a number,if the length of continuous odd digits is even and the length of continuous even digits ...
 
随机推荐
- C#遍历文件夹下全部文件
			
public static List<string> GetFile(string path, List<string> FileList, string RelativePa ...
 - 初习mysql procedure
			
1.存储过程简介 我们常用的操作数据库语言SQL语句在执行的时候需要要先编译,然后执行,而存储过程(Stored Procedure)是一组为了完成特定功能的SQL语句集,经编译后存储在数据库中,用户 ...
 - 洛谷 P1334 瑞瑞的木板==P2664 【题目待添加】
			
题目描述 瑞瑞想要亲自修复在他的一个小牧场周围的围栏.他测量栅栏并发现他需要N(1≤N≤20,000)根木板,每根的长度为整数Li(1≤Li≤50,000).于是,他神奇地买了一根足够长的木板,长度为 ...
 - Linux配置临时IP地址
			
# ifconfig 查看网卡信息,如下图所示: # ifconfig eth0 192.168.0.107 eth0表示第一块网卡,Linux中所有的设配都是文件,所以eth0是第一块网卡的文件名, ...
 - Android(java)学习笔记144:网络图片浏览器的实现(ANR)
			
1.我们在Android下,实现使用http协议进行网络通信,请求网络数据.这里是获取网络上的图片信息,让它可以显示在手机上: 但是我们这个手机连接网络是很费时间,如果我们在主线程(UI线程)中写这个 ...
 - OC 导入类 #import和@class 区别
			
objective-c中#import和@class的区别 在Objective-C中,可以使用#import和@class来引用别的类型, 但是你知道两者有什么区别吗? @class叫做forwar ...
 - JavaScript中的显示原型和隐形原型(理解原型链)
			
显式原型:prototype 隐式原型:__proto__ 1.显式原型和隐式原型是什么? 在js中万物皆对象,方法(Function)是对象,方法的原型(Function.prototype)是对象 ...
 - jquery动态实现填充下拉框
			
当点下拉框时动态加载后台数据. 后台代码 protected void doPost(HttpServletRequest request, HttpServletResponse response) ...
 - springboot文字转语音(jacob)
			
近期项目中出现在离线情况下文字转语音的需求 进过尝试返现jacob还不错 一下为开发记录: 1.pom.xml中引入jacob.jar <dependency> <groupId&g ...
 - Python模块之OS,subprocess
			
1.os 模块 简述: os 表示操作系统 该模块主要用来处理与系统相关操作 最常用的是文件操作 打开 获取 写入 删除 复制 重命名 常用操作 os.getcwd() : 返回当前文件所在文件夹路径 ...