1 solutions

  • 0
    @ 2026-11-15 12:38:05

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    int a[35];
    bool check(int num) {
        int cnt = 0;
        while (num > 0) {
            a[cnt] = num % 2;
            num /= 2;
            cnt++;
        }
        for (int i = 0; i < cnt; i++)
            if (a[i] != a[cnt - 1 - i])
                return false;
        return true;
    }
    int main() {
        int T, n;
        cin >> T;
        while (T--) {
            cin >> n;
            if (check(n))
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
        }
        return 0;
    }
    
    • 1

    Information

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