1 solutions

  • 0
    @ 2026-4-8 19:46:30

    也许你不相信,但这道题可以用九进制转十进制做,代码如下:

    #include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    
    int main() {
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	int n;
    	cin >> n;
    	while (n--) {
    		ll x;
    		cin >> x;
    		string s = to_string(x);
    		ll ans = 0, base = 1;
    		for (int i = s.length() - 1; i >= 0; i--) {
    			ll num = s[i] - '0';
    			if (num >= 8) num -= 1;
    			ans += num * base;
    			base *= 9;
    		}
    		cout << ans << '\n';
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    582
    Time
    1000ms
    Memory
    125MiB
    Difficulty
    3
    Tags
    # Submissions
    1
    Accepted
    1
    Uploaded By