hdu4722Good Numbers(dp)
这题规律其实挺明显的 打表找规律估计都可以 正规点就是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)的更多相关文章
- HDOJ(HDU).1058 Humble Numbers (DP)
HDOJ(HDU).1058 Humble Numbers (DP) 点我挑战题目 题意分析 水 代码总览 /* Title:HDOJ.1058 Author:pengwill Date:2017-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 ...
- Codeforces Round #131 (Div. 1) B. Numbers dp
题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...
- HDU 1058 Humble Numbers (DP)
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)To ...
- DP 60题 -3 HDU1058 Humble Numbers DP求状态数的老祖宗题目
Humble Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- HDU 4722 Good Numbers(DP)
题目链接 脑子有点乱,有的地方写错了,尚大婶鄙视了... 来个模版的. #include <iostream> #include <cstdio> #include <c ...
- HDU.5181.numbers(DP)
题目链接 参考. \(Description\) 将\(1,2,\cdots,n(n\leq 300)\)依次入栈/出栈,并满足\(m(m\leq 90000)\)个形如\(x\)要在\(y\)之前出 ...
- Codeforces 747F Igor and Interesting Numbers DP 组合数
题意:给你一个数n和t,问字母出现次数不超过t,第n小的16进制数是多少. 思路:容易联想到数位DP, 然而并不是...我们需要知道有多少位,在知道有多少位之后,用试填法找出答案.我们设dp[i][j ...
- Codeforces Round #673 (Div. 2) C. k-Amazing Numbers (DP,思维)
题意:有一组数,分别用长度从\([1,n]\)的区间去取子数组,要求取到的所有子数组中必须有共同的数,如果满足条件数组共同的数中最小的数,否则输出\(-1\). 题解:我们先从后面确定每两个相同数之间 ...
随机推荐
- iOS创建UUID
- (NSString *)getUUID { CFUUIDRef uuidObj = CFUUIDCreate(nil); //create a new UUID NSString * uuidSt ...
- asp.net 音乐播放器
<HTML> <HEAD><TITLE>Playback Example</TITLE> </HEAD> <BODY> < ...
- IO流02_文件过滤器
[简述] 在File类的list方法中可以接收一个FilenameFilter参数,通过该参数可以列出只满足要求的文件. FilenameFilter接口里包含了一个accept(File dir, ...
- C bit 操作
C 位 操作 一.C bit 操作(C语言 二进制位 操作) 1.Setting a bit Use the bitwise OR operator (|) to set a bit. number ...
- 创建线程的两种方式比较Thread VS Runnable
1.首先来说说创建线程的两种方式 一种方式是继承Thread类,并重写run()方法 public class MyThread extends Thread{ @Override public vo ...
- Qt-获取网络接口信息的综合示例
在前面的文章中介绍了与 获 取 本 机 网 络 信 息 相 关 的 类 常 用 的 有 4 个 , 分 别 是 : QHostAddress, QHostInfo, QNetworkInterface ...
- Mysql表操作
查看表结构: 可以使用describe或show create table语句查看表的结构: describe表名; Show create table 表名; 修改表名: Alter table 旧 ...
- JS 日期格式转换
//Json 数据年月日 返回 直接传入参数 如/Date(1379433600000)/ function GetDate(date) { if (date == null) return null ...
- ubuntu系统软件
1.办公软件:wps 2.浏览器:firefox,opera 3.思维导图:xmind 如果您有好的软件,请推荐给我,谢谢!
- AJax跨域请求百度音乐接口数据展示页面
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...