PAT 甲级 1019 General Palindromic Number(20)(测试点分析)
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 ai as ∑i=0k(aibi). Here, as usual, 0≤ai<b for all i and ak is non-zero. Then N is palindromic if and only if ai=ak−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≤109 is the decimal number and 2≤b≤109 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 "ak ak−1 ... a0". 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)(测试点分析)的更多相关文章
- PAT 甲级 1019 General Palindromic Number (进制转换,vector运用,一开始2个测试点没过)
1019 General Palindromic Number (20 分) A number that will be the same when it is written forwards ...
- PAT 甲级 1019 General Palindromic Number(简单题)
1019. General Palindromic Number (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN ...
- 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 ...
- PAT 甲级 1019 General Palindromic Number
https://pintia.cn/problem-sets/994805342720868352/problems/994805487143337984 A number that will be ...
- 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 ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- ArcGIS案例学习笔记-栅格数据分区统计(平均高程,污染浓度,污染总量,降水量)
ArcGIS案例学习笔记-栅格数据分区统计(平均高程,污染浓度,污染总量,降水量) 联系方式:谢老师,135-4855-4328,xiexiaokui@qq.com 目的:针对栅格数据,利用多边形面要 ...
- 带报表的asp.net项目不要升级
原来项目是用vs2008开发的,框架是3.5的.刚去公司项目就感觉比较乱,来来去去了几波人.所以我想统一把它升级成vs2010框架4.0. 结果页面经常报错,什么脚本找不到不存.后台脚本是用这句来添加 ...
- Javascript中的this之我见
来源:http://www.blogjava.net/baoyaer/articles/105864.html 在面向对象编程语言中,对于this关键字我们是非常熟悉的.比如C++.C#和Java等都 ...
- js高级-数组的map foreach 方法
函数式编程 sort map forEach .... jQuery() 数组的sort 方法 传入一个匿名函数 就是函数式编程 ie9 以上的浏览器支持 map 方法 map方法 返回一个新数 ...
- 学习BOS物流项目第十天
1 教学计划 1.演示权限demo 2.权限概述 a. 认证 b. 授权 3.常见的权限控制方式 a. url拦截权限控制 b. 方法注解权限控制 4.创建权限数据模型 a. 权限表 b. 角 ...
- SAP自开发程序
1.显示/查找SAP所有可执行程序清单,双击事务码执行. *&----------------------------------------------------------------- ...
- com.android.dx.command.Main with arguments
Error:Execution failed for task ':jingyeyun:transformClassesWithDexForDebug'.> com.android.build. ...
- Signed Distance Field Technique
[Distance Field Technique] 一种小纹理高清放大的技术. A distance field is generated from a high resolution image, ...
- arachni安装使用
下载:http://www.arachni-scanner.com/download/#linux 解压到不是中文的目录下:tar -zxvf arachni-1.5.1-0.5.12-linux-i ...
- javascript基础:函数参数与闭包问题
今天在写东西的时候,对函数参数的概念有些模糊,查阅相关资料后,在博客上记点笔记,方便日后复习. 首先,在js中函数参数并没有强语言中那么要求严格,他不介意传递进来多少个参数,也不在乎传进来的参数是什么 ...