http://acm.hdu.edu.cn/showproblem.php?pid=4734

各种不细心啊  居然算的所有和最大值会小于1024.。。

第二次做数位DP  不是太熟

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
#define LL __int64
int dp[][],dp2[][];
int a,b;
int pp[];
void init()
{
int i,j,g;
pp[] = ;
for(i = ; i <= ; i++)
pp[i] = pp[i-]*;
for(i = ; i <= ; i++)
dp[][i] = ;
for(i = ; i <= ; i++)
{
for(g = ; g <= ; g++)
{
for(j = ; j <= ; j++)
{
if(j+g*pp[i-]>)
continue;
dp[i][j+pp[i-]*g] += dp[i-][j];
}
}
}
for(i = ; i <= ; i++)
{
for(j = ; j <= ; j++)
{
dp[i][j] += dp[i][j-];
}
}
}
int fc(LL x)
{
int s=,o=;
while(x)
{
s+=(x%)*pp[o];
x/=;
o++;
}
return s;
}
int main()
{
int i,g,t,p[],kk=;
init();
scanf("%d",&t);
while(t--)
{
kk++;
scanf("%d%d",&a,&b);
int s1 = fc(a);
LL y = b;
int o=;
while(y)
{
o++;
p[o] = y%;
y/=;
}
int ans=;
int ts=;
for(i = o ; i>= ; i--)
{
for(g = ; g < p[i] ; g++)
{
int tt = ts+pp[i-]*g;
if(i==)
{
if(tt<=s1)
ans++;
continue;
}
if(tt>s1)
break;
ans+=dp[i-][s1-tt];
}
ts += p[i]*pp[i-];
}
if(fc(b)<=s1)
ans++;
printf("Case #%d: ",kk);
printf("%d\n",ans);
}
return ;
}

hdu4734F(x)(dp)的更多相关文章

  1. BZOJ 1911: [Apio2010]特别行动队 [斜率优化DP]

    1911: [Apio2010]特别行动队 Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 4142  Solved: 1964[Submit][Statu ...

  2. 2013 Asia Changsha Regional Contest---Josephina and RPG(DP)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...

  3. AEAI DP V3.7.0 发布,开源综合应用开发平台

    1  升级说明 AEAI DP 3.7版本是AEAI DP一个里程碑版本,基于JDK1.7开发,在本版本中新增支持Rest服务开发机制(默认支持WebService服务开发机制),且支持WS服务.RS ...

  4. AEAI DP V3.6.0 升级说明,开源综合应用开发平台

    AEAI DP综合应用开发平台是一款扩展开发工具,专门用于开发MIS类的Java Web应用,本次发版的AEAI DP_v3.6.0版本为AEAI DP _v3.5.0版本的升级版本,该产品现已开源并 ...

  5. BZOJ 1597: [Usaco2008 Mar]土地购买 [斜率优化DP]

    1597: [Usaco2008 Mar]土地购买 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 4026  Solved: 1473[Submit] ...

  6. [斜率优化DP]【学习笔记】【更新中】

    参考资料: 1.元旦集训的课件已经很好了 http://files.cnblogs.com/files/candy99/dp.pdf 2.http://www.cnblogs.com/MashiroS ...

  7. BZOJ 1010: [HNOI2008]玩具装箱toy [DP 斜率优化]

    1010: [HNOI2008]玩具装箱toy Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 9812  Solved: 3978[Submit][St ...

  8. px、dp和sp,这些单位有什么区别?

    DP 这个是最常用但也最难理解的尺寸单位.它与“像素密度”密切相关,所以 首先我们解释一下什么是像素密度.假设有一部手机,屏幕的物理尺寸为1.5英寸x2英寸,屏幕分辨率为240x320,则我们可以计算 ...

  9. android px转换为dip/dp

    /** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ public int dipTopx(Context context, float dpValue) { final floa ...

随机推荐

  1. java集合_collection子接口 list的特有方法,ArrayList类体现

    /* Collection |--List:元素是有序的,元素可以重复.因为该集合体系有索引. |--ArrayList:底层的数据结构使用的是数组结构.特点:查询速度很快.但是增删稍慢.线程不同步. ...

  2. HDU 4422 The Little Girl who Picks Mushrooms(简单题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4422 题目大意:小姑娘背着5个包去山上采蘑菇,每座山上只能用一个背包采集.三个小精灵会要她3个背包,其 ...

  3. [leetcode] 403. Frog Jump

    https://leetcode.com/contest/5/problems/frog-jump/ 这个题目,还是有套路的,之前做过一道题,好像是贪心性质,就是每次可以跳多远,最后问能不能跳到最右边 ...

  4. WIX: Hide installed program from the Add/Remove Programs window.

    Reference article : How to hide an entry in the Add/Remove Programs applet? In Wix source files, set ...

  5. (转载)SQL语句导入导出大全

    SQL语句导入导出大全 /******* 导出到excel EXEC master..xp_cmdshell 'bcp SettleDB.dbo.shanghu out c:\temp1.xls -c ...

  6. CentOS下shell显示-bash-4.1#不显示用户名路径的解决方法

    CentOS下shell显示-bash-4.1$不显示用户名路径的解决方法 问题描述: CentOS下新增一个用户,登录进去之后shell脚本的信息如下: 而不是我们经常看到的username@hos ...

  7. python的生成器

    1.生成器 >>> def func1(): ... yield 0 ... yield 1 ... >>> a=func1() >>> a.ne ...

  8. Tomcat安装与配置图文教程

    安装Tomcat之前先配置JDK,JDK的JAVA_HOME变量都必须设置好,以便Tomcat找到JDK.关闭防火墙等. 一:安装版Tomcat 1. 先下载tomcat,到http://tomcat ...

  9. Codeforces 55D Beautiful Number

    Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...

  10. C语言小结之结构类型

    C语言小结之结构类型 @刁钻的游戏 (1)枚举型类型enum COLOR {BLACK,RED,BLUE};//声明一种新的数据类型,其值分别为0,1,2但是用BLACK/RED/BLUE代表也可以这 ...