hdu 4734 F(x) --- 数位dp
来源:互联网 发布:破解网络尖兵的路由器 编辑:程序博客网 时间:2024/04/29 13:05
dp[pos][n]表示值<=n的 长度为pos位的数的个数
#include <iostream>#include <cstring>#include <string>#include <cstdio>#include <cmath>#include <algorithm>#include <vector>#include <queue>#include <map>#define inf 0x3f3f3f3fusing namespace std;int dp[20][200000],num[20];int f(int n){ int tmp,cnt; cnt=0;tmp=0; while(n) { tmp+=(n%10)*(1<<cnt); cnt++; n/=10; } return tmp;}int dfs(int n,int pos,int flag){ if(n<0) return 0; if(pos==-1) return n>=0; if(!flag&&dp[pos][n]!=-1) return dp[pos][n]; int ans,p,i; if(flag) p=num[pos]; else p=9; ans=0; for(i=0;i<=p;i++) ans+=dfs(n-i*(1<<pos),pos-1,flag&&i==p); if(!flag) dp[pos][n]=ans; return ans;}int main(){ int t,a,b,l,fa,cnt=0; memset(dp,-1,sizeof dp); scanf("%d",&t); while(t--) { cnt++; scanf("%d%d",&a,&b); fa=f(a); l=0; while(b) { num[l]=b%10; l++; b/=10; } printf("Case #%d: %d\n",cnt,dfs(fa,l-1,1)); } return 0;}
0 0
- [HDU 4734]F(x)[数位DP]
- hdu 4734 F(x)(数位DP)
- 简单数位dp-hdu-4734-F(x)
- 【数位DP】 HDU 4734 F(x)
- hdu-4734-F(x)--数位dp
- hdu 4734 F(x) --- 数位dp
- hdu 4734 F(x) (数位dp)
- [数位dp] hdu 4734 F(x)
- hdu 4734 F(x)(数位dp)
- 【HDU】4734 F(x) 数位DP
- HDU 4734 F(x)(数位DP)
- HDU 4734 F(x) (数位DP)
- hdu 4734 F(x) 数位dp
- 【数位DP】 HDU 4734 F(x)
- HDU 4734 F(x)(数位DP)
- HDU 4734 F(X) 数位DP
- Hdu 4734 F(x) (数位dp)
- HDU 4734 F(x) (数位DP)
- WCF托管在IIS、Windows Services下的性能对比
- POJ2186 Popular Cows 强连通 Tarjan
- hdu 1069 Monkey and Banana
- 3. Android搭建开发环境介绍
- WebRTC - Introduction to WebRTC architecture - 03
- hdu 4734 F(x) --- 数位dp
- WebSphere MQ的工作原理
- 差距是怎么产生的
- 在plsql中修改表的属性名
- Codeforces Round #225 (Div. 2)A. Coder
- geometry_msgs/PoseWithCovarianceStamped.msg
- 禁止拷贝网页内容 方法 代码
- jquery ajax 三级联动
- 字符串