Codeforces 861div2 A
// compile: g++ -o data data.cpp -std=gnu++20
// run: ./data < data.in
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define int long long

using namespace std;

int get_lucky(int x) {
    int minv = 11, maxv = -1;
    for (; x; x /= 10) {
        minv = min(minv, x % 10);
        maxv = max(maxv, x % 10);
    }
    return maxv - minv;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int _; cin >> _;
    while (_--) {
        int l, r;
        cin >> l >> r;
        int maxv = -1, maxind = 0;
        for (int i = l; i <= r; ++i) {
            if (get_lucky(i) > maxv) {
                maxv = get_lucky(i);
                maxind = i;
            }
            if (maxv == 9) break;
        }
        cout << maxind << endl;
    }

    return 0;
}

Comments

  1. 11 months ago
    2025-12-06 2:32:12

    Gonna try out winpkrgame. Sounds like a good time. Let the games begin. Join and play today winpkrgame!

  2. 11 months ago
    2025-12-19 13:47:13

    B52dangnhap, eh? Nghe nói vào đây chơi là phê pha lắm đó nha. Anh em nào thích cảm giác mạnh thì quất liền đi, đừng bỏ lỡ cơ hội! Check it out b52dangnhap

  3. 10 months ago
    2025-12-29 6:15:31

    789win13? Don’t know much, but I’m always down to try something new! Let me know if anyone has tried it already? Check it out: 789win13

  4. 2 months ago
    2026-9-10 13:22:36

    Just what I was looking for. Easy navigation and very responsive on all my devices. I’ll be coming back to bd7c7775 for sure

  5. 1 month ago
    2026-9-21 16:22:44

    Quick deposits and even quicker withdrawals. It’s hard to find a site as efficient as 393betcc these days. Highly satisfied!

  6. 1 month ago
    2026-9-22 15:41:37

    Solid experience overall. The graphics are crisp and the navigation is very intuitive for new players. Love 4444wim

  7. 1 month ago
    2026-9-27 21:53:32

    Super happy with the rewards program here. It really keeps things exciting and gives you more value for your time. phbet100com is the real deal.

  8. 1 month ago
    2026-9-28 10:51:01

    The jackpots here are insane! I love how easy it is to navigate the site on my phone. Big thanks to phjilihot777 for the awesome vibes.

  9. 1 month ago
    2026-9-30 12:21:33

    [2815]betsul লগইন এবং অ্যাপ ডাউনলোড | বিকাশ ক্যাসিনো ডিপোজিট,betsul লগইন করার নিয়ম জানুন এবং অ্যাপ ডাউনলোড করে অনলাইন স্লট গেম খেলার নিয়ম শিখে নিন। বিকাশ দিয়ে ক্যাসিনো ডিপোজিট করে আজই গেম শুরু করুন। visit: betsul

  10. 2 days ago
    2026-10-31 12:25:59

    The login process is super fast and secure. I appreciate how straightforward the dashboard is on 77bbbetlogin. Makes gaming much more enjoyable.

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next