1 条题解

  • 0
    @ 2025-7-5 9:17:15
    #include <bits/stdc++.h>
    using namespace std;
    int f(int now)
    {
        int a = now % 10;
        int b = now / 10 % 10;
        int c = now / 100 % 10;
        int x, y; // x 存最大的、y 存最小的
        if (b > a)
            swap(a, b);
        if (c > a)
            swap(a, c);
        if (c > b)
            swap(b, c);
        x = a * 100 + b * 10 + c;
        y = c * 100 + b * 10 + a;
        return x - y;
    }
    int main()
    {
        int n;
        cin >> n;
        int ans = 0;
        while (n != 495)
        {
            ans++;
            n = f(n);
        }
        cout << ans;
        return 0;
    }
    
    • 1

    信息

    ID
    11140
    时间
    1000ms
    内存
    128MiB
    难度
    2
    标签
    递交数
    4
    已通过
    4
    上传者