1 solutions

  • 0
    @ 2026-1-7 22:09:47

    这道题没人发题解#@admin,王王王王王王烁然来发题解了。c++代码实现:

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    int N;
        if(!(cin >> N)) return 0;
        while (N--) {
            string s;
            cin >> s;
            bool isBinary = true, isOctal = true, isDecimal = true, isHex = true;
            for (char c : s) {
                // 二进制检查
                if (c > '1') isBinary = false;
                // 八进制检查
                if (c > '7') isOctal = false;
                // 十进制检查
                if (c > '9') isDecimal = false;
                // 十六进制检查 (A-F)
                if (c > 'F' || (c < 'A' && c > '9')) isHex = false;
            }
            cout << (isBinary ? 1 : 0) << " "
                 << (isOctal ? 1 : 0) << " "
                 << (isDecimal ? 1 : 0) << " "
                 << (isHex ? 1 : 0) << "\n";
        }
        return 0;
    }
    
    
    • 1

    Information

    ID
    61
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    4
    Accepted
    3
    Uploaded By