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. 2 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. 2 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. 1 month 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

Send Comment Edit Comment


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