4521: [Cqoi2016] Mobile number time limit: ten Sec Memory Limit: MB
Submit: 382 Solved: 238
[Submit] [Status] [Discuss] Description people to choose mobile phone number when the number is good to remember, 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 3 adjacent to the same number, the number can not appear at the same time 8 and 4. 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. Mobile phone number must be 11 digits, the front does not contain the leading 0. The tool receives two numbers L and R and automatically counts the number of all the numbers in the [L,r] range that meet the criteria. L and R are also 11-bit mobile numbers. Input file content is only one row, 2 positive integer l, R, separated by a space. 10^10 < = L < = R < 10^11output
The output file contains only one row, 1 integers, indicating the number of mobile numbers that meet the criteria.
Sample Input12121284000 12121285550Sample Output5
Sample explanation
The number that satisfies the condition: 12121285000, 12121285111, 12121285222, 12121285333, 12121285550
It 's disgusting. Digital DP Questions
Six-D Status: The first dimension represents the current DP to the number, the second dimension indicates whether before the bounds, the third dimension represents the first two numbers, the fourth dimension represents the previous number, and the five dimension indicates whether there are 4 and 8, and the six dimension indicates whether there are three consecutive numbers.
#include <iostream> #include <cstdlib> #include <cmath> #include <cstring> #include <cstdio > #include <algorithm> #define F (I,j,n) for (int. i=j;i<=n;i++) #define D (i,j,n) for (int i=j;i>=n;i--) # Define ll long longusing namespace Std;ll s[15],p[15],f[15][2][10][10][4][2];inline ll read () {ll X=0,f=1;char Ch=getchar (); while (ch< ' 0 ' | | Ch> ' 9 ') {if (ch== '-') F=-1;ch=getchar ();} while (ch>= ' 0 ' &&ch<= ' 9 ') {x=x*10+ch-' 0 '; Ch=getchar ();} return x*f;} int g (int a,int b) {return ((a==8) <<1) | ( A==4) | ((b==8) <<1) | (b==4);} ll DP (ll N) {if (n<p[10]) return 0; F (i,1,11) S[i]=n/p[11-i]%10;memset (f,0,sizeof (f)), int ap=g (s[1],s[2]), fg=0;f[2][0][s[1]][s[2]][ap][0]=1; F (I,1,s[1]) F (j,0,9) {if (i==s[1]&&j>=s[2]) continue;f[2][1][i][j][g (i,j)][0]=1;} F (i,3,11) {ap|=g (s[i],s[i]) fg|= ((s[i]==s[i-1)) && (s[i-1]==s[i-2]); if (ap!=3) f[i][0][s[i-1]][s[i]][ap][ Fg]=1; F (j,0,9) F (k,0,9) F (a,0,2) F (b,0,9) {int t1=a|g (b,b), t2= (b==k) && (K==J); if (t1==3) continue;f[i][1][k][b][t1][1]+= (B<s[i]) *f[i-1][0][j][k][a][1]+f[i-1][1][j][k][a][1];f[i][1][k][b][t1][t2]+= ( B<s[i]) *f[i-1][0][j][k][a][0]+f[i-1][1][j][k][a][0];}} ll ret=0; F (i,0,9) F (j,0,9) F (a,0,2) F (b,0,1) Ret+=f[11][b][i][j][a][1];return ret; int main () {ll l=read (), R=read ();p [0]=1; F (i,1,11) p[i]=p[i-1]*10;printf ("%lld\n", DP (R)-DP (L-1)); return 0;}
bzoj4521 "CQOI2016" mobile phone number