XHXJ's LIS(数位DP)
XHXJ's LIS
http://acm.hdu.edu.cn/showproblem.php?pid=4352
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4651 Accepted Submission(s): 1946
If you do not know xhxj, then carefully reading the entire description is very important.
As the strongest fighting force in UESTC, xhxj grew up in Jintang, a border town of Chengdu.
Like many god cattles, xhxj has a legendary life:
2010.04, had not yet begun to learn the algorithm, xhxj won the second prize in the university contest. And in this fall, xhxj got one gold medal and one silver medal of regional contest. In the next year's summer, xhxj was invited to Beijing to attend the astar onsite. A few months later, xhxj got two gold medals and was also qualified for world's final. However, xhxj was defeated by zhymaoiing in the competition that determined who would go to the world's final(there is only one team for every university to send to the world's final) .Now, xhxj is much more stronger than ever,and she will go to the dreaming country to compete in TCO final.
As you see, xhxj always keeps a short hair(reasons unknown), so she looks like a boy( I will not tell you she is actually a lovely girl), wearing yellow T-shirt. When she is not talking, her round face feels very lovely, attracting others to touch her face gently。Unlike God Luo's, another UESTC god cattle who has cool and noble charm, xhxj is quite approachable, lively, clever. On the other hand,xhxj is very sensitive to the beautiful properties, "this problem has a very good properties",she always said that after ACing a very hard problem. She often helps in finding solutions, even though she is not good at the problems of that type.
Xhxj loves many games such as,Dota, ocg, mahjong, Starcraft 2, Diablo 3.etc,if you can beat her in any game above, you will get her admire and become a god cattle. She is very concerned with her younger schoolfellows, if she saw someone on a DOTA platform, she would say: "Why do not you go to improve your programming skill". When she receives sincere compliments from others, she would say modestly: "Please don’t flatter at me.(Please don't black)."As she will graduate after no more than one year, xhxj also wants to fall in love. However, the man in her dreams has not yet appeared, so she now prefers girls.
Another hobby of xhxj is yy(speculation) some magical problems to discover the special properties. For example, when she see a number, she would think whether the digits of a number are strictly increasing. If you consider the number as a string and can get a longest strictly increasing subsequence the length of which is equal to k, the power of this number is k.. It is very simple to determine a single number’s power, but is it also easy to solve this problem with the numbers within an interval? xhxj has a little tired,she want a god cattle to help her solve this problem,the problem is: Determine how many numbers have the power value k in [L,R] in O(1)time.
For the first one to solve this problem,xhxj will upgrade 20 favorability rate。
0<L<=R<263-1 and 1<=K<=10).
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 13000005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<int,char> pic;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ ll dp[][<<][];
int a[];
int k; int Maxlen(int st,int x){
for(int i=x;i<;i++){///求最长公共子序列
if(st&(<<i)) return ((st^(<<i))|(<<x));
}
return st|(<<x);
} int getone(int st){
return __builtin_popcount(st);
} ll dfs(int pos,int st,int lead,int limit){///要去掉前导0
if(pos==-) return getone(st)==k;
if(!limit&&dp[pos][st][k]!=-) return dp[pos][st][k];
ll ans=;
int up=limit?a[pos]:;
for(int i=;i<=up;i++){
ans+=dfs(pos-,(lead==&&i==)?:Maxlen(st,i),lead||i,limit&&i==a[pos]);
}
if(!limit) dp[pos][st][k]=ans;
return ans;
} ll solve(ll x){
int pos=;
while(x){
a[pos++]=x%;
x/=;
}
ll ans=dfs(pos-,,,);
return ans;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int t;
ll n,m;
memset(dp,-,sizeof(dp));
cin>>t;
for(int _=;_<=t;_++){
cin>>n>>m>>k;
ll ans=solve(m)-solve(n-);
cout<<"Case #"<<_<<": "<<ans<<endl;
} }
XHXJ's LIS(数位DP)的更多相关文章
- HDU 4352 XHXJ's LIS 数位dp lis
目录 题目链接 题解 代码 题目链接 HDU 4352 XHXJ's LIS 题解 对于lis求的过程 对一个数列,都可以用nlogn的方法来的到它的一个可行lis 对这个logn的方法求解lis时用 ...
- hdu 4352 XHXJ's LIS 数位dp+状态压缩
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4352 XHXJ's LIS Time Limit: 2000/1000 MS (Java/Others ...
- HDU.4352.XHXJ's LIS(数位DP 状压 LIS)
题目链接 \(Description\) 求\([l,r]\)中有多少个数,满足把这个数的每一位从高位到低位写下来,其LIS长度为\(k\). \(Solution\) 数位DP. 至于怎么求LIS, ...
- HDU 4352 XHXJ's LIS (数位DP+LIS+状态压缩)
题意:给定一个区间,让你求在这个区间里的满足LIS为 k 的数的数量. 析:数位DP,dp[i][j][k] 由于 k 最多是10,所以考虑是用状态压缩,表示 前 i 位,长度为 j,状态为 k的数量 ...
- hdu4352 XHXJ's LIS(数位DP + LIS + 状态压缩)
#define xhxj (Xin Hang senior sister(学姐)) If you do not know xhxj, then carefully reading the entire ...
- hdu4352 XHXJ's LIS[数位DP套状压DP+LIS$O(nlogn)$]
统计$[L,R]$内LIS长度为$k$的数的个数,$Q \le 10000,L,R < 2^{63}-1,k \le 10$. 首先肯定是数位DP.然后考虑怎么做这个dp.如果把$k$记录到状态 ...
- $HDU$ 4352 ${XHXJ}'s LIS$ 数位$dp$
正解:数位$dp$+状压$dp$ 解题报告: 传送门! 题意大概就是港,给定$[l,r]$,求区间内满足$LIS$长度为$k$的数的数量,其中$LIS$的定义并不要求连续$QwQ$ 思路还算有新意辣$ ...
- hdu 4352 XHXJ's LIS 数位DP+最长上升子序列
题目描述 #define xhxj (Xin Hang senior sister(学姐))If you do not know xhxj, then carefully reading the en ...
- hdu 4352 XHXJ's LIS 数位DP
数位DP!dp[i][j][k]:第i位数,状态为j,长度为k 代码如下: #include<iostream> #include<stdio.h> #include<a ...
随机推荐
- MD5类(MD5Helper)
项目中经常需要使用到MD5来进行加密 代码: namespace MyProject.Common { public class MD5Helper { /// <summary> /// ...
- guava 对集合的支持
- WPF 中 TextBlock 文本换行与行间距
换行符: C#代码中:\r\n 或 \r 或 \n XAML中: 或 注:\r 回车 (carriage return 缩写),\n 新行 (new line 缩写). 行间距: LineHeigh ...
- Windows下如何查看某个端口被谁占用
开发时经常遇到端口被占用的情况,这个时候总是很令人抓狂,知道被哪个进程占用还好,结束就是了,要是不知道我们该怎么办呢? 我告诉大家一个方法,^_^. 1. 开始—->运行—->cmd,或者 ...
- APP-9-文字识别-车牌识别
1.获取Access Token APP-9.1-百度应用-文字识别 2.代码部分 <!DOCTYPE html> <html> <head> <meta c ...
- List去重问题引出来的hashCode和equals方法
一.List 里面是基本类型的去重问题 import java.util.ArrayList; import java.util.HashSet; import java.util.List; imp ...
- [转载]Core Elements of a Program
原文链接 http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-c ...
- ReactiveX 学习笔记(2)创建数据流
操作符(Operators) Rx 的操作符能够操作(创建/转换/组合) Observable. Creating Observables 本文主题为创建/生成 Observable 的操作符. 这里 ...
- Windows命令行打开常用界面
本文主要介绍Windows下命令行操作打开常用界面,使用方法为在DOS命令行下输入相关命令.可以减少多次操作界面.可以尝试在命令行执行下面提到的命令感受下,快捷键主要内容包括: 1.查看计算机的基本信 ...
- 30.SSH配置文件模板和类库.md
目录 1.struts2 4.类库 1.struts2 1.<?xml version="1.0" encoding="UTF-8"?>2.< ...