hdu4352 Xhxj ' s LIS (digital DP)

Source: Internet
Author: User
Tags dota

Topic portal Xhxj ' s LIS

Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4246 Accepted Submission (s): 1772


Problem Description#define Xhxj (Xin Hang senior sister (school sister))
If you don't 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 have 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, gold medals and is 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 onl Y one team for every university to send to the world's final). Now, XHXJ are much more stronger than ever,and she'll go to the dreaming country-compete in TCO final.
As you see, xhxj all keeps a short hair (reasons unknown), so she looks like a boy (I'll not tell you she's actually A lovely girl), wearing yellow T-shirt. When she was not talking, she round face feels very lovely, attracting others to touch his face gently. Unlike God Luo ' s, another uestc God cattle who have cool and noble charm, XHXJ is quite approachable, lively, clever. The other hand,xhxj are very sensitive to the beautiful properties, "This problem have a very good properties", she always said that after acing a very hard problem. She often helps in finding solutions, even though she isn't good at the problems of that type.
XHXJ loves many games such as,dota, OCG, Mahjong, Starcraft 2, Diablo 3.etc,if can beat she in any game above, you wil L 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 does not yo U 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'll graduate after no more than one year, XHXJ also wants to fall in love. However, the man dreams have 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 is see a number, she would think whether the digits of a number is 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's very simple-to-determine a single number's power, but it's it also easy-solve this problem with the numbers within An interval? XHXJ have a little tired,she want a god cattle to help she solve this problem,the problem is:determine how many numbers ha ve the power value K in [L,r] in O (1) time.
For the first one, solve this problem,xhxj would upgrade favorability rate.

Inputfirst a integer T (t<=10000), then T lines follow, and every line have three positive integer l,r,k. (
0<l<=r<263-1 and 1<=k<=10).

Outputfor each query, print ' case #t: ans ' in a line, in which T are the number of the the test case starting from 1 and ans are The answer.

Sample Input1123 321 2

Sample outputcase #1:139

Author[email protected]

Source2012 multi-university Training Contest 6

Recommendzhuyuanchen520 | We have carefully selected several similar problems for you:6447 6446 6445 6444 6443 Test Instructions:
The topic is very long, is to ask L to R, the number of strict ascending sub-series of the numbers of the length of the number of K. Note that the definition of the longest ascending subsequence here is the same as the LIS, which is not required to be continuous, so you can use 10-bit binary notation for 0~9 occurrences, and O (NLOGN) to update the same method as the LIS
Code:
#include <stdio.h>#include<string.h>typedefLong Longll;ll n,m,k;ll dp[ +][1<<Ten][ One];intbit[ +];intGetnew (intXints) {     for(inti=x;i<Ten; i++)    {        if(s& (1<<i))return(s^ (1<<i)) | (1&LT;&LT;X);//find the first one larger than X to replace    }    returns| (1<<x);}intGetnum (ints) {    intCnt=0;  while(s) {if(s&1) cnt++; S>>=1; }    returnCNT;} ll Dfs (intPosintStaBOOLLeadBOOLlimit) {    if(pos==-1)returnGetnum (STA) = =K; if(!limit&&dp[pos][sta][k]!=-1)returnDp[pos][sta][k]; intUp=limit?bit[pos]:9; ll ans=0;  for(intI=0; i<=up;i++) {ans+=dfs (pos-1, (lead&&i==0)?0: Getnew (I,sta), lead&&i==0, limit&&i==Bit[pos]); }    if(!limit) dp[pos][sta][k]=ans; returnans;} ll solve (ll x) {intlen=0;  while(x) {Bit[len++]=x%Ten; X/=Ten; }    returnDFS (len-1,0,1,1);}intMain () {intT; scanf ("%d",&T); intNcase=0; Memset (DP,-1,sizeof(DP));  while(t--) {scanf ("%lld%lld%d",&n,&m,&k); printf ("Case #%d:",++ncase); printf ("%lld\n", Solve (m)-solve (n1)); }}


hdu4352 Xhxj ' s LIS (digital DP)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.