n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)
输出Yes或者No
并且输出该格式
又是水题。。。

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring> using namespace std;
const int maxn=;
int a[maxn];
int n,b;
int main()
{
scanf("%d %d",&n,&b);
int cnt=;
int tmp=n;
if(tmp==){
cnt=;
a[]=;
}
while(tmp){
a[cnt]=tmp%b;
//printf("cnt:%d a:%d\n",cnt,a[cnt]);
cnt++;
tmp=tmp/b;
}
bool flag=true;
for(int i=;i<=cnt/;i++){
if(a[i]!=a[cnt--i]){
flag=false;
break;
}
} if(flag)
printf("Yes\n");
else
printf("No\n");
printf("%d",a[cnt-]);
for(int i=cnt-;i>=;i--){
printf(" %d",a[i]);
}
printf("\n");
return ;
}

PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚的更多相关文章

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

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

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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) 1019. General Palindromic Number (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  7. 【PAT甲级】1019 General Palindromic Number (20 分)

    题意: 输入两个正整数n和b(n<=1e9,2<=b<=1e9),分别表示数字的大小和进制大小,求在b进制下n是否是一个回文串,输出“Yes”or“No”,并将数字n在b进制下打印出 ...

  8. 1019. General Palindromic Number (20)

    生词以及在文中意思 forward 向前地 backward 向后地 palindromic 回文的 base 基数(如十进制的10 和二进制的2) numeral system 数制 decimal ...

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

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

随机推荐

  1. 深入浅出SharePoint2013——Search Schema配置

    如果增加了新的Metadata,请上传文件到文档库后,并确保每个字段都填充了数据.然后执行全文爬网. 这样才会产生对应新的管理属性.

  2. 【13】python time时间模块知识点备查

    表示时间的三种形式 # 时间模块 '''UTC(世界协调时间):格林尼治天文时间,世界标准时间,在中国来说是UTC+8DST(夏令时):是一种节约能源而人为规定时间制度,在夏季调快1个小时 时间的表示 ...

  3. [python]关于列表增加元素的几种操作

    1.insert方法,该方法包含两个参数,第一个参数为插入的位置参数,第二个参数为插入内容 a = [0,0,0] b = [1,2,3] a.insert(0,b) print a 输出: [[1, ...

  4. 【转】WINS服务器与DNS服务器有什么区别?

    1.WINS实现的是IP地址和计算机名称的映射,DNS实现的是IP地址和域名的映射.2.WINS作用的范围是某个内部网络,DNS的范围是整个互联网.简单说明一下:WINS实现的是IP地址和计算机名称的 ...

  5. Spark项目之电商用户行为分析大数据平台之(七)数据调研--基本数据结构介绍

    一.user_visit_action(Hive表) 1.1 表的结构 date:日期,代表这个用户点击行为是在哪一天发生的user_id:代表这个点击行为是哪一个用户执行的session_id :唯 ...

  6. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP

    <?php class Car { var $color = "add"; function Car($color="green") { $this-&g ...

  7. 用BCP从SQL Server 数据库中导出Excel文件

    BCP(Bulk Copy Program)是一种简单高效的数据传输方式在SQL Server中,其他数据传输方式还有SSIS和DTS. 这个程序的主要功能是从数据库中查询Job中指定step的执行信 ...

  8. (三)Lua脚本语言入门(数组)

    又要找工作了,变的忧虑了,唯有学习才让内心变得踏实,今天玩了一下午的王者荣耀,正事都忘了...... 如果认为所谓的毅力是每分每秒的“艰苦忍耐”式的奋斗,那这是一种很不足的心理状态.毅力是一种习惯,毅 ...

  9. 希尔排序算法的php实现

    虽然现在各种程序语言都有其各自强大的排序库函数,但是这些底层实现也都是利用这些基础或高级的排序算法. 理解这些复杂的排序算法还是很有意思的,体会这些排序算法的精妙~ 一.希尔排序(shell sort ...

  10. array_multisort函数,以及多维数组下排序的应用,并与usort函数对比

    以前比较少用这个函数,大部分自己接触的业务里,处理稍微大一些的数组的时候几乎都是从db里取出来的,在db里就order by了. 最近倒是用了次,这个函数用来排序很强大,有点类似于sql中的order ...