1019 General Palindromic Number(20 分)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers.

Although palindromic numbers are most often considered in the decimal system, the concept of palindromicity can be applied to the natural numbers in any numeral system. Consider a number N>0 in base b≥2, where it is written in standard notation with k+1 digits a​i​​ as ∑​i=0​k​​(a​i​​b​i​​). Here, as usual, 0≤a​i​​<b for all i and a​k​​ is non-zero. Then N is palindromic if and only if a​i​​=a​k−i​​ for all i. Zero is written 0 in any base and is also palindromic by definition.

Given any positive decimal integer N and a base b, you are supposed to tell if N is a palindromic number in base b.

Input Specification:

Each input file contains one test case. Each case consists of two positive numbers N and b, where 0<N≤10​9​​ is the decimal number and 2≤b≤10​9​​ is the base. The numbers are separated by a space.

Output Specification:

For each test case, first print in one line Yes if N is a palindromic number in base b, or No if not. Then in the next line, print N as the number in base b in the form "a​k​​ a​k−1​​ ... a​0​​". Notice that there must be no extra space at the end of output.

Sample Input 1:

27 2

Sample Output 1:

Yes
1 1 0 1 1

Sample Input 2:

121 5

Sample Output 2:

No
4 4 1

注意:1、当数字N为0, 要求输出也为0(测试点5 答案错误):这里我用do...while

2、当进制超过10的时候,比如16进制的ABCDE,虽然可以用字母代替,当进制高更高(字母个数不足),就不能再用单字符判断,所以这里回文采用了双向链表存储每一位数,正序和逆序比较每一位的数是否相等即可。(测试点2 答案错误、测试点4 格式错误)

PAT 甲级 1019 General Palindromic Number(20)(测试点分析)的更多相关文章

  1. PAT 甲级 1019 General Palindromic Number (进制转换,vector运用,一开始2个测试点没过)

    1019 General Palindromic Number (20 分)   A number that will be the same when it is written forwards ...

  2. PAT 甲级 1019 General Palindromic Number(简单题)

    1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...

  3. PAT甲级——1019 General Palindromic Number

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  4. PAT 甲级 1019 General Palindromic Number

    https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984 A number that will be ...

  5. PAT Advanced 1019 General Palindromic Number (20 分)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  6. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...

  7. PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) (进制转换,回文数)

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

  8. 1019 General Palindromic Number (20)(20 point(s))

    problem A number that will be the same when it is written forwards or backwards is known as a Palind ...

  9. PAT甲级——A1019 General Palindromic Number

    A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...

随机推荐

  1. ceph部署手册

    CentOS7.2部署Luminous版Ceph-12.2.0 在CentOS7.2上安装部署Luminous版Ceph-12.2.0.由于ceph的Luminous版本默认使用bluestore作为 ...

  2. platform 系统是windows还是liunx

    import platform # 判断当前代码运行的系统是windows还是liunx print(platform.architecture()) print(platform.platform( ...

  3. DM 9000网卡驱动移植

    1. 由于内核已经带有DM9000 网卡的驱动,所以主要移植工作是在板文件中添加 platform_device 结构,并加入 ok6410_devices[] __initdata 数组. 代码如下 ...

  4. ubuntu下zaibbix3.2报警搭建

    1.安装sudo apt install sendmail 2.测试发送邮件: echo "正文!" | mail -s 标题 XXX@qq.com 3.成功后继续安装邮件服务器. ...

  5. 从源码安装Node

    [从源码安装Node] Nodejs官网未并提供i686架构的bin,为了在i686架构cpu下使用Nodejs,需要从源码编译. 1../configure 2.make 3.make instal ...

  6. Emulating private methods with closures

    [Emulating private methods with closures] JavaScript does not provide a native way of doing this, bu ...

  7. linux 根据服务名称批量杀死进程

    ps -ef |grep python |awk '{print $2}'|xargs kill -9

  8. Java volatile关键字的用法

    volatile不能解决同步问题 如果想要理解volatile关键字的作用不得不先了解Java内存模型 摘抄一下来自百度百科的话 在本次线程内,当读取一个变量时,为提高存取速度,编译器优化时有时会先把 ...

  9. Jmeter+Ant+Jenkins实现接口自动化(转载)

    转载自  http://www.cnblogs.com/chengtch/p/6145867.html 本文转载于上面的网址,稍作修改,实用性更强. Jmeter是压力测试.接口测试工具,Ant是基于 ...

  10. 第十章 优先级队列 (b4)完全二叉堆:批量建堆