Links: https://www.luogu.org/problemnew/show/P4124
Title Description
When people choose their mobile phone number, they want the number to be good and auspicious. For example, the number contains several adjacent to the same number, does not contain homophonic unlucky numbers. These factors are also taken into account by mobile operators when issuing new numbers, which are sold separately from numbers that contain certain features. To facilitate early planning, operators want to develop a tool to automate the number of numbers in a number segment that satisfies a feature.
Tool needs to detect the number characteristics of two: the number to appear at least 33 adjacent to the same number, the number can not appear at the same time 88 and 44. The number must contain two characters to satisfy the condition. The number that satisfies the condition, such as 13000988721, 23333333333, 14444101000. The numbers that do not meet the criteria are for example: 1015400080, 10010012022.
The cell phone number must be11 digits, preceded by no leading00. Tool receives two numbersLL andRR, automatically statistics out[L,r]the numberof all the numbers in the [L, R] range that meet the criteria. lL and RR are also11-digit mobile phone numbers.
Input/output format
Input format:
The input file content is only one line, 2 2 positive integers separated by a space l,rL,R.
Output format:
The output file contains only one row, 11 integers, indicating the number of mobile numbers that meet the criteria.
Input and Output sample input sample #: Copy
12121284000 12121285550
Output Example # #: Replication
5
Description
Example explanation: The number that satisfies the condition: 12121285000, 12121285111, 12121285222, 12121285333, 12121285550.
Data range:10^< Span class= "msupsub" > 1 0≤l≤ r<10^ < Span class= "Sizing reset-size6 size3 mtight" >11&NBSP; < Span class= "Mord mtight" >
< Span class= "Mrel" > puzzle: Digital DP, It's quite easy to yy out, but to get rid of the leading 0 case, <10^10 is illegal
//Luogu-judger-enable-o2#include <bits/stdc++.h>using namespacestd;#definell Long Long#defineRT RegisterConst intM =2530; ll dp[ -][Ten][2][2][2][2];intdigit[ -], CNT, tot, Bg[m];ll dfs (intDepBOOLFBOOLBoth,BOOLOkintTBOOLA4,BOOLA8) { if(!DEP)return(( ! (A4 & A8)) &OK); if(!f && dp[dep][t][two][ok][a4][a8]! =-1)returnDp[dep][t][two][ok][a4][a8]; RTinti = f? DIGIT[DEP]:9; LL TMP=0; for(; I >=0; i--){ if(dep==tot&&i==0)Continue; BOOLNtwo, NOK =OK; if(both && (t = = i)) Ntwo =0, NOK =1; Else if(i = = t) Ntwo =1; ElseNtwo =0; TMP+ = DFS (DEP-1, F & (i = = Digit[dep]), ntwo, NOK, I, A4 | (i = =4), A8 | (i = =8)); } if(!f) Dp[dep][t][two][ok][a4][a8] =tmp; returntmp;} llGet(ll a) {memset (DP,-1,sizeof(DP)); Tot=0; while(a) {digit[++tot] = a%Ten; A/=Ten; } if(tot< One)return 0; ll ans= DFS (tot,1,0,0,0,0,0); returnans;} ll read () {ll x=0; ll f =1;Charc =GetChar (); while(c<'0'|| C>'9'){if(c=='-') f=-1; c=GetChar ();} while(c<='9'&&c>='0') {x=x*Ten+c-'0'; c=GetChar ();} returnx*F;}intMain () {///freopen ("1.in", "R", stdin); //freopen ("My.out", "w", stdout); intT; Memset (DP,-1,sizeof(DP)); ll L= Read (), R =read (); ll Ans2=GetL1); ll Ans1=Get(R); //cout<<ans1<< "" <<ans2;cout<<ans1-ans2<<Endl;}//10000000000 10000012345View Code
P4124 [CQOI2016] Mobile phone number