hdu_4734_F(x)(数位DP水)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4734
题意:给你一个F(x)的定义,然后给你a,b,问你在0到b包括b有多少个数满足F(x)<=F(a)
题解:dp[i][j]为dp到第i位的和为j的方案
#include<cstdio>
#include<cstring>
#define F(i,a,b) for(int i=a;i<=b;i++) int t,a,b,fa,dp[][],ct,dig[],len; int dfs(int pos,int sum,bool inf){
if(!pos)return ;
if(!inf&&dp[pos][sum]!=-)return dp[pos][sum];
int end=inf?dig[pos]:,ans=,tp;
F(i,,end){
tp=sum-i*(<<(pos-));
if(tp>)ans+=dfs(pos-,tp,inf&&(i==end));
}
if(!inf)dp[pos][sum]=ans;
return ans;
} int main(){
scanf("%d",&t);
memset(dp,-,sizeof(dp));
F(ic,,t){
printf("Case #%d: ",ic);
scanf("%d%d",&a,&b);
for(fa=ct=;a;a/=,ct++)fa+=a%*(<<ct);
for(len=;b;b/=)dig[++len]=b%;
printf("%d\n",dfs(len,fa+,));
}
return ;
}
hdu_4734_F(x)(数位DP水)的更多相关文章
- bzoj 1026 [SCOI2009]windy数——数位dp水题
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1026 迷恋上用dfs写数位dp了. #include<iostream> #in ...
- uestc 250 数位dp(水)
/* 数位dp 水题 开两维一个记录长度,一个记录上一个数 */ #include<stdio.h> #include<string.h> #define N 13 int d ...
- BZOJ 1026: [SCOI2009]windy数 【数位dp】
Description windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道,在A和B之间,包括A和B,总共有多少个windy数? In ...
- 【BZOJ-1026】windy数 数位DP
1026: [SCOI2009]windy数 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 5230 Solved: 2353[Submit][Sta ...
- 【BZOJ-1833】count数字计数 数位DP
1833: [ZJOI2010]count 数字计数 Time Limit: 3 Sec Memory Limit: 64 MBSubmit: 2494 Solved: 1101[Submit][ ...
- Fzu2109 Mountain Number 数位dp
Accept: 189 Submit: 461Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description One ...
- hdu 2451 Simple Addition Expression(数位DP )成败在于细节
亚洲区域赛的题,简单的数位DP题,注重细节. 任何细节都有可能导致wa,所以没有绝对的水题. 把握好细节,此题便A. #include<stdio.h> __int64 getans(__ ...
- 数位DP练习
水题 发布时间: 2017年6月22日 19:15 最后更新: 2017年6月23日 20:10 时间限制: 1000ms 内存限制: 128M 描述 给一个数n,求0~n内有多少个数满足 ...
- 几道数位DP
因为这几天写的几道数位DP大多都太水..而且也确实没什么好讲所以就扔到一起了. [hdu4772]Good Numbers 要求统计区间内 各位数之和能被10整除 的数的个数. 练手,f[i][j][ ...
随机推荐
- jquery学习笔记2——jq效果
一.显示隐藏: 可以使用show()和hide()方法来显示隐藏: $("#hide").click(function(){ $("p").hide(); }) ...
- 重读The C programming Lanuage 笔记三:简单计算器程序
//简单计算器 #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <str ...
- servlet之过滤器(转载)
林炳文Evankaka原创作品.转载请注明出处http://blog.csdn.net/evankaka 一.Filter 1.过滤器的概念 Java中的Filter 并不是一个标准的Servlet ...
- Mac下配置Maven环境变量
Mac下配置Maven环境变量 1.先到Apache官网下载maven压缩包.下载地址:http://maven.apache.org/download.cgi 2.Maven是用Java开发的,所以 ...
- 【转】HDU1028
转自博客园ID:2108,老卢同志 http://www.cnblogs.com/--ZHIYUAN/p/6102893.html Ignatius and the Princess III Time ...
- iOS开发富文本
NSMutableAttributedString * attributedStr = [[NSMutableAttributedString alloc] initWithString:@" ...
- 关于对象存入NSUserDefaults
#import <Foundation/Foundation.h> @interface Student : NSObject <NSCoding> @property (no ...
- keycode 锁键盘按键(只能输入数字)
$('#lottoStage').keydown(function(){ if(event.keyCode == 46 || event.keyCode==8){ $(this).val(''); r ...
- 使用某些Widows API时,明明包含了该头文件,却报错“error C2065: undeclared identifier”
在使用一些新版本的API,或者控件的新特性(比如新版的ComCtl32.dll)的时候,你可能会得到“error C2065: undeclared identifier.“这个错误.原因是这些功能是 ...
- Nginx简单配置,部分来源于网络
nginx.conf listener监听端口 server_name监听域名 location{}是用来为匹配的 URI 进行配置,URI 即语法中的“/uri/”.location / { }匹 ...