链接

这题规律其实挺明显的 打表找规律估计都可以 正规点就是DP

算出第N位所包含的good number的数量 如果给出的数是N+1位 就枚举各位上比原来小的数 加上下一位的dp值

一个i写成g了 纠结了半天。

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

hdu4722Good Numbers(dp)的更多相关文章

  1. HDOJ(HDU).1058 Humble Numbers (DP)

    HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-2 ...

  2. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  3. Codeforces Round #131 (Div. 1) B. Numbers dp

    题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...

  4. HDU 1058 Humble Numbers (DP)

    Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  5. DP 60题 -3 HDU1058 Humble Numbers DP求状态数的老祖宗题目

    Humble Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  6. HDU 4722 Good Numbers(DP)

    题目链接 脑子有点乱,有的地方写错了,尚大婶鄙视了... 来个模版的. #include <iostream> #include <cstdio> #include <c ...

  7. HDU.5181.numbers(DP)

    题目链接 参考. \(Description\) 将\(1,2,\cdots,n(n\leq 300)\)依次入栈/出栈,并满足\(m(m\leq 90000)\)个形如\(x\)要在\(y\)之前出 ...

  8. Codeforces 747F Igor and Interesting Numbers DP 组合数

    题意:给你一个数n和t,问字母出现次数不超过t,第n小的16进制数是多少. 思路:容易联想到数位DP, 然而并不是...我们需要知道有多少位,在知道有多少位之后,用试填法找出答案.我们设dp[i][j ...

  9. Codeforces Round #673 (Div. 2) C. k-Amazing Numbers (DP,思维)

    题意:有一组数,分别用长度从\([1,n]\)的区间去取子数组,要求取到的所有子数组中必须有共同的数,如果满足条件数组共同的数中最小的数,否则输出\(-1\). 题解:我们先从后面确定每两个相同数之间 ...

随机推荐

  1. MongoDB使用记录

    安装服务 使用以下命令将MongoDB安装成为Windows服务.笔者的MongoDB目录为D:\Program Files\mongodb mongod --logpath "D:\Pro ...

  2. struts2的java文件中不能直接弹出script对话框

    需要引入接口 ServletResponseAware public class Login extends ActionSupport implements SessionAware,Servlet ...

  3. Arithmetic Expression

    时间限制:2000ms 单点时限:200ms 内存限制:256MB 描述 Given N arithmetic expressions, can you tell whose result is cl ...

  4. Poj/OpenJudge 1094 Sorting It All Out

    1.链接地址: http://poj.org/problem?id=1094 http://bailian.openjudge.cn/practice/1094 2.题目: Sorting It Al ...

  5. Linux中的sed

    sed [选项] [动作] 文件 选项:     -n :静默模式.使用-n则只有经过sed处理的那一行.     -e :允许多重编辑:       -f :结果默认输出到终端,使用-f会将结果写在 ...

  6. Java Web开发中的名词解释

    1.JVM Java虚拟机,class文件的运行时环境,就好比软件运行在操作系统一样,java要运行在JVM中才行,这也是Java之所以支持扩平台的基础. 2.Servlet/JSP 是满足一定接口需 ...

  7. Apache的多路处理模块MPM:Prefork Worker Event

    如何确认当前apache使用哪种模式 通过/etc/init.d/httpd中的来确认系统apache的运行脚本路径 apachectl=/usr/sbin/apachectl httpd=${HTT ...

  8. controller.pp 各组件的安装顺序

    controller 属性:         admin_address => $controller_node_address,         public_address => $c ...

  9. SQL sum case when then else【转】

    数据库 t 表     b 表内容        Id        Name      胜负        1          张三     胜        2          李四     ...

  10. 属性观察者willSet与didSet

    在Swift中使用willSet和didSet这两个特性来监视属性的除初始化之外的属性值变化. willSet里面是新值,即属性即将要变为的值:didSet里面是旧值,即属性变化之前的值. impor ...