Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- /* ------- declaration ------- */
- long long l, r;
- long long cr, ans;
- long long calc(int n) {
- long long base = 1;
- long long res = 0;
- do {
- if (n&1)
- res += 7*base;
- else
- res += 4*base;
- n >>= 1, base *= 10;
- }
- while (n > 1);
- return res;
- }
- /* ------- ~~~~~~~~~~~ ------- */
- /* ----------------- main func ----------------- */
- void query() {
- cin >> l >> r;
- for (int i = 2; true; ++i) {
- cr = calc(i);
- if (cr > r) break;
- if (cr >= l)
- ans += (cr - l + 1)*cr,
- l = cr + 1;
- }
- ans += (r - l + 1)*cr;
- cout << ans;
- }
- /* ----------------- ~~~~~~~~~ ----------------- */
- int main(){
- //freopen("Test.INP", "r", stdin);
- //freopen("Test.OUT", "w", stdout);
- cin.tie(NULL)->sync_with_stdio(false);
- /* ------- setup ------- */
- srand(time(0));
- cout << fixed << setprecision(2);
- int t = 1; for (; t--; query());
- /* ------- ~~~~~ ------- */
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement