dfs打表,再用二分
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[10000009];
ll cnt = 0;
void dfs(ll x) {
if (x > 1000000000) return;
a[cnt++] = x;
dfs(x * 10 + 7);
dfs(x * 10 + 4);
}
int main() {
ll l, r, ans = 0;
cin >> l >> r;
dfs(4); dfs(7);
a[cnt++] = 4444444444;
sort(a, a + cnt);
int L = lower_bound(a, a + cnt, l) - a;
int R = lower_bound(a, a + cnt, r) - a;
for (int i = L; i <= R; i++) {
ans += (min(a[i], r) - l + 1) * a[i];
l = a[i] + 1;
}
cout << ans << endl;
}