现在主要问题是不知道哪里写挂了……
求大佬们捉虫 Q^Q
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#define Heriko return
#define Deltana 0
#define Romanno 1
#define S signed
#define LL long long
#define R register
#define I inline
#define CI const int
#define mst(a, b) memset(a, b, sizeof(a))
#define ON std::ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
template<typename J>
I void fr(J &x)
{
static short f(1);
char c=getchar();
x=0;
while(c<'0' or c>'9')
{
if(c=='-') f=-1;
c=getchar();
}
while (c>='0' and c<='9')
{
x=(x<<3)+(x<<1)+(c^=48);
c=getchar();
}
x*=f;
}
template<typename J>
I void fw(J x,bool k)
{
x<0?x=-x,putchar('-'):1;
static short stak[35],top(0);
do
{
stak[top++]=x%10;
x/=10;
}
while(x);
while(top) putchar(stak[--top]+'0');
k?puts(""):putchar(' ');
}
LL l,r,f[12][12][12][2][2][2][2];
int a[12];
LL DFS(int p1,int p2,int p3,bool same,bool limit,bool h4,bool h8)
{
if(h4&h8) Heriko Deltana;
if(!p1) Heriko same;
if(f[p1][p2][p3][same][limit][h4][h8]!=-1) Heriko f[p1][p2][p3][same][limit][h4][h8];
int up(limit?a[p1]:9);LL res(0);
for(R int i(0);i<=up;++i) res+=DFS(p1-1,i,p2,same|(i==p2 and i==p3),limit|(i==up),h4|(i==4),h8|(i==8));
if(!limit) f[p1][p2][p3][same][limit][h4][h8]=res;
Heriko res;
}
I LL DP(LL x)
{
if(x<1e10) Heriko Deltana;
int len(0);LL res(0);
mst(f,-1);
while(x) a[++len]=x%10,x/=10;
for(R int i(1);i<=a[len];++i) res+=DFS(10,i,0,0,i==a[len],i==4,i==8);
Heriko res;
}
S main()
{
fr(l),fr(r);
fw(DP(r)-DP(l-1),1);
Heriko Deltana;
}