因为区间很大暴力搞不行,但是这个10位数以内的幸运数字只有2046种,所以可以先dfs预处理出所有的幸运数字,然后求每个幸运数字的贡献。
#include<bits/stdc++.h>
using namespace std;
#define ls rt<<1
#define rs (rt<<1)+1
#define PI acos(-1)
#define eps 1e-8
#define ll long long
#define fuck(x) cout<<#x<<" "<<x<<endl;
typedef pair<int,int> pii;
const int inf=2e9;
const int maxn=1e6+10;
int d[4][2]={1,0,-1,0,0,1,0,-1};
//int lowbit(int x){return x&-x;}
//void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);}
//int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;}
inline ll read() {
ll s = 0,w = 1;
char ch = getchar();
while(!isdigit(ch)) {
if(ch == '-') w = -1;
ch = getchar();
}
while(isdigit(ch))
s = s * 10 + ch - '0',ch = getchar();
return s * w;
}
inline void write(ll x) {
if(x < 0)
putchar('-'), x = -x;
if(x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
ll a[maxn];
int cnt;
void dfs(ll val,int dep){
a[++cnt]=val;
if(dep==10)
return ;
dfs(val*10+4,dep+1);
dfs(val*10+7,dep+1);
}
int main(){
cnt=0;
dfs(0,0);
sort(a+1,a+cnt+1);
int l,r;
ll ans=0;
l=read();
r=read();
for(int i=2;i<=cnt;i++)
if(a[i]>=l)
{
if(a[i]>=r){
ans+=1LL*(r-l+1)*a[i];
break;
}
ans+=1LL*(a[i]-l+1)*a[i];
l=a[i]+1;
}
write(ans);puts("");
return 0;
}