1 solutions

  • 0
    @ 2024-12-5 18:19:39

    C++ :

    #include <iostream>
    #include <cmath>
    
    using namespace std;
    
    
    int main() {
    	uint64_t n; cin >> n;
    	int ct = 0; // 计数器
    	while (n != 495) {
    		int a, b, c;
    		a = n % 10; n /= 10; // 分别取出各位数
    		b = n % 10; n /= 10;
    		c = n;
    		if (a > c) swap(a, c); // 排列顺序
    		if (b > c) swap(b, c);
    		if (a > b) swap(a, b);
    		n = (c * 100 + b * 10 + a) - (a * 100 + b * 10 + c);
    		++ct;
    	}
    	cout << ct;
    }
    
    
    • 1

    Information

    ID
    9150
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By