페이지

11068번: 회문인 숫자

https://www.acmicpc.net/problem/11068


$O(tlgx)$


#include<cstdio>
int t, x, a[20], i, j;
int main() {
    for (scanf("%d", &t); t--;) {
        scanf("%d", &x);
        for (i = 2; i <= 64; i++) {
            int cnt = 0;
            for (j = x; j; j /= i) a[cnt++] = j%i;
            for (j = 0; j < cnt; j++) if (a[j] ^ a[cnt - 1 - j]) break;
            if (j == cnt) break;
        }
        printf("%d\n", i <= 64);
    }
    return 0;
}

댓글 없음 :

댓글 쓰기