美文网首页
1019 General Palindromic Number

1019 General Palindromic Number

作者: 79d12e22ec53 | 来源:发表于2019-08-01 13:54 被阅读0次
    #include <cstdio>
    #include <cstring>
    
    bool judge(int num[], int len) {
        for(int i=0; i<=len/2; i++) {
            if(num[i] != num[len-1-i]) return false;
        }
        return true;
    }
    
    int main(int argc, char *argv[]) {
        int N, b;
        int num[40];
        scanf("%d %d", &N, &b);
        
        int len=0;
        do{
            num[len++] = N%b;
            N = N/b;
        }while(N != 0);
        
        bool flag = judge(num, len);
        if(flag == true) printf("Yes\n");
        else printf("No\n");
        printf("%d", num[len-1]);
        for(int i=len-1-1; i>=0; i--) {
            printf(" %d", num[i]);
        }
        
        return 0;
    }
    
    

    相关文章

      网友评论

          本文标题:1019 General Palindromic Number

          本文链接:https://www.haomeiwen.com/subject/mdmqdctx.html