HDU2089[不要62]--数位DP
来源:互联网 发布:java软件是什么 编辑:程序博客网 时间:2024/06/05 16:55
【链接】
hdu2089
【解题报告】
简单的数位DP
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=25;int n,m,ans,len,f[maxn][10],a[maxn];inline int Read(){ int res=0; char ch=getchar(); while (ch<'0'||ch>'9') ch=getchar(); while (ch>='0'&&ch<='9') res=res*10+ch-48,ch=getchar(); return res;}int Dfs(int x,int las,bool pd){ if (x>len) return 1; if (!pd&&f[x][las]) return f[x][las]; int MAX=9; if (pd) MAX=a[x]; f[x][las]=0; for (int i=0; i<=MAX; i++) if ((las!=6&&i!=4)||(las==6&&i!=2&&i!=4)) f[x][las]+=Dfs(x+1,i,pd&(i==a[x])); return f[x][las];}void Work(){ memset(f,0,sizeof(f)); a[0]=len=0;int x=n-1; while (x) a[++len]=x%10,x/=10; for (int i=1; i<=len/2; i++) swap(a[i],a[len-i+1]); ans=Dfs(1,0,1); memset(f,0,sizeof(f)); a[0]=len=0; x=m; while (x) a[++len]=x%10,x/=10; for (int i=1; i<=len/2; i++) swap(a[i],a[len-i+1]); printf("%d\n",Dfs(1,0,1)-ans); n=Read(); m=Read();}int main(){ freopen("2089.in","r",stdin); freopen("2089.out","w",stdout); n=Read(); m=Read(); while (n||m) Work(); return 0;}
阅读全文
1 0
- 【数位DP】 hdu2089 不要62
- 【数位DP】不要62 HDU2089
- HDU2089:不要62(数位DP)
- hdu2089 不要62 数位dp
- hdu2089 不要62 (数位DP)
- HDU2089 不要62 数位DP
- Hdu2089 - 不要62 - 数位dp
- hdu2089 不要62 数位dp
- 【数位DP】【HDU2089】不要62
- [HDU2089] 不要62 && 数位DP
- hdu2089 不要62 数位dp
- HDU2089 不要62 (数位DP)
- HDU2089 不要62 数位DP
- HDU2089 不要62【数位DP】
- hdu2089不要62【数位dp】
- hdu2089 不要62 数位DP
- hdu2089 不要62(数位DP)
- hdu2089 不要62(数位dp)
- 利用matlab画混淆矩阵(confusion matrix)
- Cool(动态规划)
- CocosCreator android 获取deviceId
- Laravel-学习笔记-路由(Route)
- leetcode
- HDU2089[不要62]--数位DP
- 关于TLS经验小结(上)
- JDBC 增删改查操作示例
- spring + redis 集群
- Android surfaceflinger(3)-DisplayDevice封装
- [luogu1108&2687][USACO4.3]Buy Low, Buy Lower(STL乱搞+高精度)
- 原型与继承
- 角色设计流程图
- c++实现一元稀疏多项式加减